how to crop a binary image horizontally if vertical length exceeds a certain value?
1 次查看(过去 30 天)
显示 更早的评论
I have a couple of binary images depicting hand gestures. There are some side effects in those images, that is, images include arm part (down the wrist till elbow). Please view the images attached! I am going to crop this part according to some condition. Is there any way of writing a code for this?
For example: finding the vertical center of white region, or, finding the vertical length of the white region and cut out the bottom part percentage-wise?
Please note that the content of an image (hand) may have different verticality like in the 3rd attached image, so a suggested method should consider up to 40 % curvature as vertical.
Thank you for your ideas!
0 个评论
采纳的回答
KSSV
2017-5-8
I = imread('1.jpg') ;
[y,x] = find(I) ;
L = max(x)-min(x) ;
B = max(y)-min(y) ;
Icrop = imcrop(I,[min(x) min(y) L B]) ;
Crops only the region of interest.
4 个评论
KSSV
2017-5-11
Try this:
I = imread('3.jpg') ;
imshow(I) ;
[y,x] = find(I) ;
x0 = min(x) ; x1 = max(x) ;
y0 = min(y) ; y1 = max(y) ;
%%Form a rectangle
B = x1-x0 ; % horizontal length
L = y1-y0 ; % vertical length
L0 = 200 ; % specified length, change as you wish
if L > L0
dL = L-L0 ;
end
I(x0+dL:end,:) = 0 ;
imshow(I)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!