Removing an area from an image
Ältere Kommentare anzeigen
Hi - I'm looking to segment, calculate area and skeletonise a microscope image. I've gotten my segmentation working pretty ok (thanks to some threads I read by Image Analyst), and now want to remove particles in the image smaller that a certain size. I know the pixel dimensions of the image, and I have a scalebar, but how do I start referencing the image size in terms of micrometres instead of pixels? The image is 4140x3096 pixels, equalling 11 pixels per micrometer, and I wish to remove objects smaller than 20 micrometer squared.
Thanks in advance for any assistance or pointers.
I attach the image, and my current code below.

%Call HSVMask function, and assign result to img_segmented
Inimage=imread('R7URFS.jpg');
figure, imshow(Inimage);title('Original Image');
img_segment=HSVMask(Inimage); % call function HSVMask()
imwrite(img_segment,'R7URFS-Segment.jpg');
%figure, imshow(img_segment);title('Segmented Image Returned From Function (HSVMask)');
img_segment=imread('R7URFS-Segment.jpg');
img_gray=rgb2gray(img_segment);
figure, imshow(img_gray);title('Grayscale Segmented Image');
% Shrink and dilate the image
shrinkxtimes=28;
dilatextimes=15;
img_thin_x = bwmorph(img_gray, 'shrink', shrinkxtimes);
%figure,imshow(img_thin_x);title('Shrunk Image');
img_thin_dilated=bwmorph(img_thin_x, 'dilate', 1);% dilate the lines to connect broken parts.
%figure,imshow(img_thin_dilated);title('Dilated Image x1');
%[img_small_removed]=remove_small_objects(img_thin_dilated,4148.916); % call function remove_small_objects
%figure,imshow(img_small_removed);title('Small Parts Removed - Returned from Function (remove_small_objects)');
img_thin_dilated_2=bwmorph(img_thin_dilated, 'dilate', dilatextimes);
%figure,imshow(img_thin_dilated_2);title('Dilated Again x15');
se=strel('disk',10);
img_thin_dilated_2=imfill(img_thin_dilated_2,'holes');
img_thin_dilated_2=imopen(img_thin_dilated_2,se);
Ls=Zheng_Skeletonise(img_thin_dilated_2);
img_skeleton=bwmorph(Ls, 'dilate', 2);
figure,imshow(Ls);title('Complete Skeletonised Image');
imwrite(Ls,'R7URFS-Skeleton.jpg');
return
2 Kommentare
KALYAN ACHARJYA
am 6 Feb. 2019
qualling 11 pixels per micrometer, and I wish to remove objects smaller than 20 micrometer squared.
What I have undestood from your above text, you want to remove those region having less than 220x220 pixels, please correctify ?
Jocko
am 6 Feb. 2019
Akzeptierte Antwort
Weitere Antworten (1)
KALYAN ACHARJYA
am 6 Feb. 2019
Bearbeitet: KALYAN ACHARJYA
am 6 Feb. 2019
BW2=bwareaopen(binary_image,size_pixel);
%Resultant image having only more than size_pixels area
% But it does not look for shape of the regions
Have you look at the folowing functions? Matlab
The function ismember is useful with regionprops, bwconncomp, and labelmatrix for creating a binary image containing only objects or regions that meet certain criteria.
4 Kommentare
Jocko
am 6 Feb. 2019
KALYAN ACHARJYA
am 6 Feb. 2019
Bearbeitet: KALYAN ACHARJYA
am 6 Feb. 2019
See classify the problem in two steps- Suppose im is the processed binary image
Step 2: Apply the following
BW2=bwareaopen(result1_image,size_pixel); %result2_image
Step 3: result_image=im && result2_image
Hopefully you can do the all three operations in single line. Goes to our master @ImageAnalyst sir, let see.
Jocko
am 6 Feb. 2019
KALYAN ACHARJYA
am 6 Feb. 2019
Bearbeitet: KALYAN ACHARJYA
am 6 Feb. 2019
As you stated that region can any shape, then directly apply the following
BW2=bwareaopen(binary_image,size_pixel);
Good Wishes!
Kategorien
Mehr zu Region and Image Properties finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!