简体   繁体   中英

matlab divide an image according to the user input

I have an Image : 3个数字

I want to manually divide the image into the parts as show below: The division of the image should be user controlled. I should be able to take the user input of the rectangular squares in which I am trying to divide the Image.

The output is shown below : 3个数字

How can I do this in matlab?

After operating on the individual images can I join them back together to make the image as one ?

Use imrect to create an interactive rectangular selection tool on top of the input image. Look closely at the second example.

Once the user has selected a rectangel, you can use imcrop to get the corresponding part.
Saving the relative position of the selected rectangle (ie, the position vector [xywh] ) you can then "re-embbed" the part into the original image at the same location.

I finally got it . Thanks !

Img = imread('cameraman.tif');
figure();
imshow(Img);
h = imrect();
crop_area = wait(h);
cropped = imcrop(Img, crop_area);
imshow(cropped);

This works well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM