2
$\begingroup$

I need to find affine projections of rectangular content in an image, e.g., paintings, postcards, posters, etc.

I was surprised that FindImageShapes only supports lines, circles, and eclipses!

Is there a built-in way to do this in v14? And if not, how to extend FindImageShapes?

Example:

img = Import@
  "https://www.wolframcloud.com/obj/ffcb49f6-e44c-4c2b-a2e3-3cdc842ae085"
FindImageShapes[img, "Rectangle"]

enter image description here

First and worst attempt:

comp = ImageSegmentationComponents[img];
Colorize@comp

area = Times @@ ImageDimensions[img];
rects = SortBy[
   ComponentMeasurements[
    comp, {"BoundingBox", "Rectangularity", 
     "Area"}], -#[[2, 2]]^(1/2) + (#[[2, 3]]/area) &];
HighlightImage[img, {Red, Rectangle @@@ rects[[1 ;; UpTo[15], 2, 1]]}]

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ Please post an example. $\endgroup$
    – cvgmt
    Commented May 1 at 2:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.