How can I crop a set of non-binary images automatically depending on the size and position of each image?
1 回表示 (過去 30 日間)
古いコメントを表示
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/883490/image.png)
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 件のコメント
採用された回答
DGM
2022 年 2 月 3 日
編集済み: DGM
2022 年 2 月 4 日
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 件のコメント
その他の回答 (1 件)
yanqi liu
2022 年 2 月 7 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!