Crop a specific area for the sem image

조회 수: 3 (최근 30일)
luo jingcheng
luo jingcheng 2023년 10월 27일
답변: Image Analyst 2023년 10월 27일
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.
  댓글 수: 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.
luo jingcheng
luo jingcheng 2023년 10월 27일
the whole black section with sclerites in it

댓글을 달려면 로그인하십시오.

채택된 답변

Akira Agata
Akira Agata 2023년 10월 27일
How about the following?
% Read the image
I = imread("");
% 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, :));
% Visualize the result
montage(cImg, "BackgroundColor", "w")
  댓글 수: 1
luo jingcheng
luo jingcheng 2023년 10월 27일
that is sooo helpful!
In fact, I initially planned to separate the entire SEM image before croping each of the image because I was concerned that the text below might affect the results during the binarization process. you have directly implemented this step. Now, I intend to adjust the background of each image to be completely black (some image contain adjacent sclerites)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
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.


Help CenterFile Exchange에서 Image Filtering and Enhancement에 대해 자세히 알아보기


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by