Binarization to Crop Image
Afficher commentaires plus anciens
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!
Réponse acceptée
Plus de réponses (1)
Brian Peoples
le 7 Juil 2020
0 votes
3 commentaires
Image Analyst
le 7 Juil 2020
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
le 8 Juil 2020
Image Analyst
le 8 Juil 2020
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.
Catégories
En savoir plus sur Image Segmentation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


