Binarization to Crop Image
이전 댓글 표시
In my code I use binarization to crop my region of interest from a photograph to observe lightness values as shown bellow:

This is my code:
I0 = imread(f{3}); %f{3} is some random photo in this case
I1 = I0(:,:,3); % select 3d channel
I2 = im2bw(I1,graythresh(I1)-0.1); % binarization
figure(n);
imshow(I2)
h = msgbox('select region of interest');
uiwait(h)
p = ginput(1); % pick point
I3 = bwselect(~I2,p(1),p(2)); % select region of interest
I4 = cat(3,I3,I3,I3);
I5 = uint8(I4).*I0; % crop rgb image
imshow(I5);
My question is as follows:
I made some modifications to my image and now it is:

My current code (even when I try and tweak the threshold) won't strictly pick up the piece of hair! I really ned help just getting the hair to pick up in the crop!
채택된 답변
추가 답변 (1개)
Brian Peoples
2020년 7월 7일
0 개 추천
댓글 수: 3
Image Analyst
2020년 7월 7일
A little time in optimizing and standardizing your image capture conditions will make the image analysis algorithm tremendously easier. For example there are lots of cheap light boxes on Amazon.com for image capture, like the
They range from $40 to a few hundred dollars. They are for the casual, non-scientific, non-professional user, despite what they say. And as a professional, I ought to know. I call these "Ebay quality" or "Etsy quality" since that is really the market they sell to - the casual user who likes to take pictures of things to sell them online.
Of course you can get much better if you want to have your machine shop build something for you from aluminum rails, high quality camera mounts such as these RAM Mounts, lamps from AdvancedIllumination or SmartVisionLights, professional machine vision industrial or scientific cameras, and other professional components.
Good luck.
Brian Peoples
2020년 7월 8일
Image Analyst
2020년 7월 8일
I'd just wrap a piece of paper with text on it over the barrel and see what rows and columns the image gets too blurry for you. Then just analyze the image, or crop it, within those boundaries.
카테고리
도움말 센터 및 File Exchange에서 Image Segmentation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


