Auto cropping of pollen
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
DIMITRIOS THEODOROPOULOS
el 19 de En. de 2019
Comentada: DIMITRIOS THEODOROPOULOS
el 20 de En. de 2019
Ι want ot do the following:
I have this image and i want to create ROI of a pollen automatically.If i imcrop for example a small region with ,let say 5 pollens, i want to take 5 cropped images
of the pollens ,with the pollens centered and specific dimensions of the ROI.For example this image
Summarizing :
i imcrop and i get as many cropped images as the pollens are included inside the imcropped
image.How can i do it???
0 comentarios
Respuesta aceptada
Image Analyst
el 19 de En. de 2019
Editada: Image Analyst
el 19 de En. de 2019
First of all, take a black shot with no pollen in there, and divide your image by that blank shot to do background correction. I'm attaching a demo.
After that, you can do thresholding and cropping like I do in my Image Processing Tutorial: My File Exchange
You might want to convert your image to a binary image using the Color Thresholder on the Apps tab of the tool ribbon. Use the Export button to export the function to do the binarization. Basically to crop each, you'd do
props = regionprops(binaryImage, 'BoundingBox');
figure % Bring up new figure.
spRows = ceil(sqrt(length(props)));
for k = 1 : length(props)
thisBB = props(k).BoundingBox;
subImage = imcrop(originalImage, thisBB);
subplot(spRows, spRows, k);
imshow(subImage);
end
If you want a specific width and margin to your bounding boxes, then take thisBB and modify it. Like, to make it 50 pixels wider and 75 pixels taller:
thisBB(1) = thisBB(1) - 50;
thisBB(3) = thisBB(3) + 100;
thisBB(2) = thisBB(2) - 75;
thisBB(4) = thisBB(4) + 150;
Or, to make it always 200 pixels wide and tall, do this:
midx = thisBB(1) + thisBB(3)/2; % Right side plus half the width.
thisBB(1) = midx - 100;
thisBB(3) = thisBB(1) + 199;
midy = thisBB(2) + thisBB(4)/2;
thisBB(2) = midy - 100;
thisBB(4) = thisBB(2) + 199;
3 comentarios
Image Analyst
el 20 de En. de 2019
It saves every image, however since you forgot to change the name, they all get saved to the same filename. Why did you not create a new filtename with sprintf()? Like
filename = sprintf('Grain #%d.png', k);
imwrite(subImage, filename);
If you still get a round spot instead of a pollen grain, attach your image, and code where you background corrected, binarized, cropped, and saved the image.
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!