250x250
Link
๋์ GitHub Contribution ๊ทธ๋ํ
Loading data ...
Notice
Recent Posts
Recent Comments
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Python
- numpy
- ์ธ๋์ํ๋ง
- ๋ฐ์ดํฐ๋ถ์์ ๋ฌธ๊ฐ
- ์ค๋ฒ์ํ๋ง
- datascience
- ๋ฐ์ดํฐ๋ถ๊ท ํ
- ๋น ๋ฐ์ดํฐ๋ถ์๊ธฐ์ฌ
- opencv
- ADP
- ๋น ๋ฐ์ดํฐ
- ๊ตฐ์งํ
- ADsP
- ๋ฐ์ดํฐ๋ถ์์ค์ ๋ฌธ๊ฐ
- LDA
- ๋ ๋ฆฝํ๋ณธ
- iloc
- ํ์ด์ฌ
- dataframe
- ๋ฐ์ดํฐ๋ถ์
- Lambda
- ๋์ํ๋ณธ
- ํฌ๋กค๋ง
- DBSCAN
- pandas
- ์ฃผ์ฑ๋ถ๋ถ์
- PCA
- ํ ์คํธ๋ถ์
- t-test
- ์๋ํด๋ผ์ฐ๋
Archives
Data Science LAB
[Python] OpenCV ๊ธฐ์ด 6 - ์ด๋ฏธ์ง ์๋ฅด๊ธฐ(Crop) ๋ณธ๋ฌธ
๐ฅ๏ธ Computer Vision/Opencv
[Python] OpenCV ๊ธฐ์ด 6 - ์ด๋ฏธ์ง ์๋ฅด๊ธฐ(Crop)
ใ ใ ใ ใ 2022. 8. 6. 17:02728x90
1. ์์ญ์ ์๋ผ์ ์๋ก์ด ์ด๋ฏธ์ง ์ฐฝ์ ํ์
image[์ธ๋ก์์ญ, ๊ฐ๋ก์์ญ]
import cv2
img = cv2.imread('img.jpg')
# img.shape (390,640,3)
crop = img[100:200,200:400] #์ธ๋ก ๊ธฐ์ค 100:200, ๊ฐ๋ก๊ธฐ์ค 200:400
cv2.imshow('img',img)
cv2.imshow('crop',crop)
cv2.waitKey(0)
cv2.destroyAllWindows()
ํฌ๋กญ๋ ์์ญ์ด ์๋ก์ด ์๋์ฐ ์ฐฝ์ผ๋ก ํ์๋จ
2. ์์ญ์ ์๋ผ์ ๊ธฐ์กด ์๋์ฐ์ ํ์
import cv2
img = cv2.imread('img.jpg')
# img.shape (390,640,3)
crop = img[100:200,200:400]
img[100:200, 400:600] = crop
cv2.imshow('img',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
3. ๋ง์ฐ์ค๋ก ์ง์ ์์ญ ์ถ์ถ
import cv2
import numpy as np
img = cv2.imread('img.jpg')
x,y,w,h = cv2.selectROI('img',img, False)
if w and h :
roi = img[y:y+h, x:x+w]
cv2.imshow('crop',roi)
cv2.moveWindow('crop',0,0) # crop ์ด๋ฏธ์ง ์ผ์ชฝ ์ ์ฐฝ์ผ๋ก ์ด๋
cv2.imshow('img',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
crop ํ๊ณ ์ ํ๋ ๋ถ๋ถ์ ์ ํํ๋ค, enter ๋ฒํผ์ ๋๋ฅด๋ฉด
๋ค์๊ณผ ๊ฐ์ด ํฌ๋กญ๋ ๋ถ๋ถ์ด ์ ์๋์ฐ์ฐฝ์ ๋จ๊ฒ ๋๋ค.
728x90
'๐ฅ๏ธ Computer Vision > Opencv' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python] OpenCV ๊ธฐ์ด 8 - ์ด๋ฏธ์ง ๋ณํ(ํ๋ฐฑ, ํ๋ฆผ) (0) | 2022.08.08 |
---|---|
[Python] OpenCV ๊ธฐ์ด 7 - ์ด๋ฏธ์ง ๋์นญ ๋ฐ ํ์ (0) | 2022.08.07 |
[Python] OpenCV ๊ธฐ์ด 5 - ์ด๋ฏธ์ง ํฌ๊ธฐ์กฐ์ (resize) (0) | 2022.08.05 |
[Python] OpenCV ๊ธฐ์ด 4 - ์ด๋ฏธ์ง ๋ฐ ๋์์ ์ ์ฅ (0) | 2022.08.04 |
[Python] OpenCV ๊ธฐ์ด 3 - ์ด๋ฏธ์ง ์์ ํ ์คํธ ์ ๋ ฅ (0) | 2022.08.03 |
Comments