How to do automatic image cropping?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi there, The following image
contains two rectangles- one on the top of the other. They are on a black background, have close shades of light gray and have different orientations. The upper rectangle is always close to the left side of the image.
I managed to crop the desired polygon (with fixed vertex values). But I want to apply it for a set of images and the size of the two rectangles might vary from one image to other (the upper reclangle remains always close to the left side to the image). I want to be able to do the cropping automatically. Can you help please.
Thanks.
4 Kommentare
Image Analyst
am 25 Mär. 2013
Please elaborate on this: ">Why are you doing this? What is the need, or use case? To extract one rectangle overlapping another." That is not a use case. That sounds just like some kind of homework assignment or project with no real world use, A real world use case would be something like you have a stack of white tiles that workers stacked out of the kilns and a robot with suction cup or parallel gripper fingers needs to orient its arm-mounted to pick up each tile and put each tile into a box at a fixed, known orientation. So why would any care that you have a bunch of images with the top paper segmented out? What good are they? Who is going to act or make decisions based on those images and what are those acts or decisions going to be?
Antworten (2)
Sean de Wolski
am 22 Mär. 2013
Bearbeitet: Sean de Wolski
am 22 Mär. 2013
- Threshold ( graythresh() and im2bw())
- Get the boundingbox ( regionprops() )
- Extract it using simply indexing
Image Analyst
am 22 Mär. 2013
Thresholding is easy. And there is a corner() function to find corners. But if you want to get two rectangles out you'll need an algorithm for what to do if you have 4, 5, 6, 7, or 8 corners. Do you have that? That's no so straightforward. Plus what if they both overlap so that you have one long rectangle at, say, 1.7 times the area? You'll also need special code to handle that.
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!