Crop a specific area for the sem image
2 次查看(过去 30 天)
显示 更早的评论
I have many images containing SEMs and annotations. I want to crop out just the SEM content, the black square regions, using Matlab. This requires Matlab to locate the black borders of the SEMs and record those coordinates, then use imcrop to crop the specific areas. I don't want the white content within the SEMs to affect the determination.
thanks!
2 个评论
KSSV
2023-10-27
Why don't you show us what areas you want from the image. You may highlite the regions using paint.
采纳的回答
Akira Agata
2023-10-27
How about the following?
% Read the image
I = imread("https://www.mathworks.com/matlabcentral/answers/uploaded_files/1522566/image.png");
% Create ROI mask
Igray = rgb2gray(I);
BW = Igray>50;
BW = imclearborder(BW);
BW = bwareafilt(BW, [5000 Inf]); % Ignore small ROIs (<5000 pixel)
% Calculate bounding box for each ROI
s = regionprops("table", BW);
s = sortrows(s, "Area", "descend");
% Crop each region from the image
cImg = cell(height(s), 1);
for kk = 1:height(s)
cImg{kk} = imcrop(I, s.BoundingBox(kk, :));
end
% Visualize the result
figure
montage(cImg, "BackgroundColor", "w")
更多回答(1 个)
Image Analyst
2023-10-27
It's a generic, general purpose demo of how to threshold an image to find blobs, and then measure things about the blobs, and extract certain blobs based on their areas or diameters. Note how each of the coins in the demo image is cropped out to its own image. Just replace the image with yours. And you can use bwareafilt to get rid of small blobs, like the letters or other annotations in the image.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Read, Write, and Modify Image 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!