1

I am trying to get clean grid data from this image (don't mind the tilt, it is incidental).

enter image description here

This means no noisy dots and a uniform grid representing the situation. I am doing fairly well using morphology, doing:

closing_rectangle1 ()
opening_rectangle1 ()
select_shape ('rectangularity')

in different orders and amounts to clean up some noise.

enter image description here

It is not as complete and uniform as I'd like to achieve, so I'm wondering if Halcon has a better way of doing this (other than morphology or as an addition to) that I am not aware of. The rectangle-orientation and pattern in the grid can be different but the size is always the same.

3
  • What is the exact output that you need from this image? Coordinates of the intersections or something else? Commented Jul 20, 2022 at 14:48
  • Uniform and complete regions, region center coordinates, coordinates of the intersections would probably also work I think. Commented Jul 20, 2022 at 14:56
  • Is the number of compartments always familiar e.g. 5x4 like now? Commented Jul 20, 2022 at 14:59

1 Answer 1

2
read_image (Image, 'D:/OneDrive - Subpixel d.o.o/Other/Stackoverflow/5/uZKGw.png')
threshold (Image, Region, 128, 255)
connection (Region, ConnectedRegions)
select_shape_std (ConnectedRegions, SelectedRegions, 'max_area', 70)

** One region is disconnected, which interferes with watershed algorithm
dilation_circle (SelectedRegions, RegionDilation, 1.5)

get_image_size (Image, Width, Height)
gen_image_const (Image1, 'byte', Width, Height)
paint_region (RegionDilation, Image1, ImageResult, 255, 'fill')

watersheds (ImageResult, Basins, Watersheds)
select_shape (Basins, SelectedRegions1, 'area', 'and', 4000, 8000)

** Transform everything to rectangles 2 (rect1 if you can ignore the angle)
shape_trans (SelectedRegions1, RegionTrans, 'rectangle2')

** Reduce the regions a bit to achive separation
erosion_circle (RegionTrans, RegionErosion, 3.5)

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Awesome, watershed is THE solution to my issue!

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.