comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » creating a 2D mask for image filtering
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: creating a 2D mask for image filtering [message #77292 is a reply to message #77215] Thu, 18 August 2011 07:28 Go to previous messageGo to previous message
David Higgins is currently offline  David Higgins
Messages: 13
Registered: August 2009
Junior Member
Ah, yes, that is definitely better. The step-down is still smoothed out, but with better preservation of the central to-be-left-alone section.

I had another idea, which was to plot concentric circles as seen in
http://www.idlcoyote.com/tips/make_circle.html
to approximate the filter shape a little better before smoothing, with the result that the smoothing needn't be as aggressive, and the central section is even better preserved.

PRO apod_filter
SET_PLOT, 'WIN'
image = DIST(512)
WINDOW, 0, TITLE = 'Test data before filtering'
SHADE_SURF, image
siz = SIZE(image, /DIMENSIONS)
minRadius = MIN(siz)/2;

thisDevice = !D.Name
SET_PLOT, 'Z'
DEVICE, SET_RESOLUTION=siz
ERASE, COLOR=0

; 20-point Hanning-shape step-down from the edge of minRadius,
; using concentric circles, starting at 0.8*minRadius, to zero at minRadius
steps = REVERSE(FINDGEN(20))
filter_width = 0.8
radius_frac = filter_width + steps*((1-filter_width)/N_ELEMENTS(steps))
gap_idx = (minRadius/2*(1-(radius_frac-filter_width)/(1-filter_width)) )
Hanning_shape_colorvals = FIX(100* (0.5*(1-cos((2*!PI*gap_idx)/minRadius))) )
FOR i=0,N_ELEMENTS(Hanning_shape_colorvals)-1 DO BEGIN
points = (2*!PI/99.0) * FINDGEN(100)
x_c = siz[0]/2-1 + FIX(ROUND(radius_frac[i]*minRadius)) * COS(points)
y_c = siz[1]/2-1 + FIX(ROUND(radius_frac[i]*minRadius)) * SIN(points)
circ = TRANSPOSE([[x_c],[y_c]])
POLYFILL, circ, color=Hanning_shape_colorvals[i]
; Possible problem with ellipses instead of a circle; dependent on image
; aspect ratio, see http://www.idlcoyote.com/tips/make_circle.html
ENDFOR
filter = smooth(float(TVRD())/100, 10, /EDGE_TRUNCATE)

SET_PLOT, thisDevice
WINDOW, 3, TITLE = 'Filter to be applied'
SHADE_SURF, filter
WINDOW, 4, TITLE = 'Filtered image'
SHADE_SURF, filter*image
END

I see your point about TVCircle to keep circles circular. Thanks. I'll look into that next.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Integration
Next Topic: Storing data in an array inside a structure MUCH slower in IDL 8.2.2

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 00:57:31 PDT 2025

Total time taken to generate the page: 0.48523 seconds