MATLAB Answers

Crop images along a row instead of column

13 ビュー (過去 30 日間)
no zoop
no zoop 2019 年 10 月 6 日
編集済み: Akshit Agarwal 2019 年 10 月 14 日
Hi,
I have a collage of freshwater plankton and want to crop them along a row instead of by column. I have attached the binary picture, I also have the original image. I want to crop all the images in the collage. The code I use to crop by column is...
for k = 1 : numberOfBlobs(n) % Loop through all blobs.
% Find the bounding box of each blob.
thisBlobsBoundingBox = blobMeasurements{n}(k).BoundingBox; % Get list of pixels in current blob.
% Extract out this zoop into it's own image.
subImage = imcrop(OG_images{n}, thisBlobsBoundingBox);
% Saving the cropped image
%% did not add code as it is not needed

  0 件のコメント

サインイン to comment.

採用された回答

Akshit Agarwal
Akshit Agarwal 2019 年 10 月 9 日
編集済み: Akshit Agarwal 2019 年 10 月 14 日
Hi,
There is no such thing as cropping along row or column, the second parameter in imcrop function is a rectangle [xmin ymin width height] i.e. the bounding box of the subimage that you want to crop out of your image.
So if your code crops along the column then your 'thisBlobsBoundingBox' variable is what is telling the function to crop along the column. Go through your 'blobMeasurements', see how it is defined and change it accordingly.
For example: For an image of size 100 X 100.
subimage1 = imcrop(image, [0, 0, 100, 50])
subimage2 = imcrop(image, [0, 50, 100, 50])
will divide the original image along the row (horizontally) and subimage1 and subimage2 will hold both the cropped parts of the image.
Have a look at this documentation: Crop an Image and also at this: imcrop for further reference.

  1 件のコメント

no zoop
no zoop 2019 年 10 月 14 日
So I use bwlabel() to label the images in my collage and it also labels them by column and then row. Could I do something to the labelling matrix to change the order of bwlabel(). I would then feed the newly labeled image into regionsprops....code below
labeledImage = bwlabel(our_images_binary,8); % Label each blob so we can make measurements of it
blobMeasurements{n} = regionprops(labeledImage, our_images_binary, 'all');

サインイン to comment.

その他の回答 (0 件)

サインイン してこの質問に回答します。

製品


リリース

R2019a

Translated by