How can I crop a set of non-binary images automatically depending on the size and position of each image?
1 view (last 30 days)
Show older comments
I have a dataset of more than 1000 images. When I load them into Matlab (R2021b), they all are the same size, but the actual image information is stored differently in them, because they are padded unequally (I cannot supply image examples since they consist of medical data).
Is there any way to perform this kind of heterogeneous cropping automatically? Is there any function that I have missed in my research? I have already checked imcrop and regionprops, but they do not offer what I need I think. Here you have a schematic representation of my problem:
I would like to crop the white areas and keep the images only without manually specifying the coordinates and the positions of the cropping.
Many thanks in advance,
0 Comments
Accepted Answer
DGM
on 3 Feb 2022
Edited: DGM
on 4 Feb 2022
If the excess area is a solid color (you mentioned white), then I and ImageAnalyst mention multiple methods in this thread:
Note the limitations of each.
If the padding area has other stuff in it (e.g. text labels, ui controls), the process may need to be more involved, perhaps resorting to simple image segmentation to find the cropping coordinates.
If there isn't really a distinct padded area, but just a shift in the region of interest within a large image area, then you'll need to come up with a means of programmatically identifying the ROI.
0 Comments
More Answers (1)
yanqi liu
on 7 Feb 2022
yes,sir,may be use image segment method,such as locate image rectangle,and then make it as logical mask matrix,then apply it to origin image to crop it
if possible,may be upload your some image to analysis
0 Comments
See Also
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!