Clear Filters
Clear Filters

Cropping image into multiple images at certain coordinates, but the positions need verification first

3 views (last 30 days)
I have an image of a test chart that I scanned with a scanner. The thing I want to do is cut the image in to pieces (rectangles) at a coordinate with a given size. I've tried this:
this let's you make a rectangle that will crop out. (but it wont be the right size from the start)
imcrop([xpos, ypos, w, h);
this lets you define a size and a coordinate but it wont let you verify if it's the right place on the image.
Is there a way of combining both? I want to get the x,y,w,h out of a matrix and then it should show on a plot, if it covers the area I want it to cover I can go on to the next step. and when they are all in the right place (they should be initially but if they aren't I still want to change the position) I want to press a button and have it cut the pieces out. The cutting shouldn't be so hard but I can't think of a way to show all rectangles at the same time, and then press a button to do all cuts at the same time.
I hope you understand my problem, english isn't my main language so I understand it might be a little vague.
Kind regards,

Answers (2)

Thomas Koelen
Thomas Koelen on 23 Mar 2015
The main problem for now is that Matlab should show the crop-rectangles before actually cropping them, to verify if the rectangles are at the right place. I was thinking that I should maybe show the rectangles at positions with imrec, then save the position and then use these positions to crop with imcrop.
Any ideas on this?
Kind regards,

Image Analyst
Image Analyst on 23 Mar 2015
I'm not sure what you're talking about. Calling imcrop() with no arguments does let you click and drag out a box and give you handles for adjusting the sides. Then you can double click inside the box.
Thomas Koelen
Thomas Koelen on 24 Mar 2015
Edited: Thomas Koelen on 24 Mar 2015
Allright, I'll do that for sure! Found another way to do it (kind off)
h = imrect(gca, [10 10 100 100]);
Is there a way to show multiple imrect at the same time? instead of having to click each one individually?
Image Analyst
Image Analyst on 24 Mar 2015
I don't know - never tried. What if you do this:
h1 = imrect(gca, [10 10 100 100]);
h2 = imrect(gca, [120 120 100 100]);
h3 = imrect(gca, [230 230 100 100]);
Not sure, though, if they're have to click on them in the same order they were put up. Would just have to try it and see.

Sign in to comment.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!