Problem masking multiple regions. [message #37593] |
Thu, 08 January 2004 13:08 |
Bruce Bowler
Messages: 128 Registered: September 1998
|
Senior Member |
|
|
I have a problem and I hope someone here can "See the error of my ways".
I have a grey-scale png file. I need to extract the boundaries of the
various regions in the image. I've tried the following but it fails after
finding the bounds of "a couple" of the regions that I know it should find.
pro map_parts, file = file, target = target
ok = query_png(file, s)
window, 1, xsize = s.dimensions[0], ysize = s.dimensions[1]
window, 2, xsize = s.dimensions[0], ysize = s.dimensions[1]
x = read_png(file)
subarr = reform(x[0, *, *])
wset, 1
tvscl, subarr
ix = where(subarr eq target, count)
rcount = 0
while (count gt 0 and rcount lt 10) do begin
bounds = find_boundary(ix)
plots, bounds, /device, color = fsc_color('green')
region = obj_new('IDLanROI', bounds)
mask = region -> computemask(dimensions = size(subarr, /dimensions),
mask_rule = 2)
iy = where(mask gt 0, ycount)
if (ycount gt 0) then subarr(iy) = 0
obj_destroy, region
rcount = rcount + 1
print, rcount, ycount, count
ix = where(subarr eq target, count)
end
wset, 2
tvscl, subarr
end
The end goal, all things being right with the world, is the get the
vertices of each distinct region.
I'll be happy to send anyone who's interested, a file (~55K png file) that
demonstrates the problem.
--
+-------------------+--------------------------------------- ------------+
Bruce Bowler | A bipartisan issue is a problem neither party knows
1.207.633.9600 | how to solve. - Joe Hickman
bbowler@bigelow.org |
+-------------------+--------------------------------------- ------------+
|
|
|