Automatic cropping of an image using threshold
Show older comments
I have an grayscale image with a intensity distribution. The peaks of the light might be at one locatoion or contain several peaks at different locations. I like to remove all areas with "lower intensity" to make the analysis faster on an smaller image.
Thus I would like to threadhold the grayscale image to say 63% of max intensity to find the regions that is of interest. Then crop the grayscale image to include all those regions in a new smaller image for further image analysis.
Which functions can do this?
Previously I have done this manually (cropping and using the eye to determine the area).
A1 = imread('red-laser-beam-grayscale.jpg');
imshow(A1,[])
%improfile
% makes image smaller
figure(5)
histeq(A1);
% take out coordianates
pts = readPoints(A1, 2);
p1=[pts(1,1) pts(2,1)]
p2=[pts(1,2) pts(2,2)]
% crop and plot
imCell_cut= A1(p1(2):p2(2),p1(1):p2(1));
imshow(imCell_cut,[])
Edit: Added an example image, see attachments for images with the manual cropping from code above. Want this automated at threshold 63%.
Accepted Answer
More Answers (0)
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!