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

Home » Public Forums » archive » Does IDL has histogram matching function?
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: Does IDL has histogram matching function? [message #33001 is a reply to message #32955] Thu, 21 November 2002 14:23 Go to previous messageGo to previous message
Paul Sorenson is currently offline  Paul Sorenson
Messages: 48
Registered: May 2002
Member
I'm not sure if the implementation of FCN is correct. I'm still thinking
about it. Here is an example:

pro histogram_test

filename = filepath('ctscan.dat', subdir=['examples', 'data'])
image = read_binary(filename, data_dims=[256, 256])

x = findgen(256)/255. ;Ramp from 0 to 1.
y = exp(-((x-.5)/.2)^2) ;Gaussian curve

fcn = total(y, /cumulative)
gauss_image = hist_equal(image, fcn=fcn)

d = total(histogram(gauss_image, min=0, max=255), /cum) ;density
function

device, decomp=0
loadct, 39
;
;When we request a custom distribution curve, the result (in white)
;doesn't touch the ideal curve (in red). Is this an indication
;that the implementation of keyword FCN is incorrect?
;
! p.multi = [0, 2, 1]
plot, bytscl(d)
oplot, bytscl(fcn), color=254 ;red

uniform_image = hist_equal(image)

d = total(histogram(uniform_image, min=0, max=255), /cum) ;density
function
;
;When we request the default uniform distribution, the result (in white)
;touches the ideal curve (in red).
;
plot, bytscl(d)
oplot, bindgen(256), color=254 ;red

end


"David Fanning" <david@dfanning.com> wrote in message
news:MPG.18432a801e0db738989a2e@news.frii.com...
> Paul Sorenson (aardvark62@msn.com) writes:
>
>> There is an undocumented keyword to HIST_EQUAL that looks like it
>> might do the same thing as Davids HistoMatch. Here is an example:
>>
>> filename = filepath('ctscan.dat', subdir=['examples', 'data'])
>> image = read_binary(filename, data_dims=[256, 256])
>>
>> desired_hist = histogram(hist_equal(image), min=0, max=255)
>>
>> window, xsize=3*256, ysize=256
>> tv, image, 0
>> tv, hist_equal(image), 1
>> tv, hist_equal(image, fcn=total(desired_hist, /cumulative)), 2
>> end
>
> I think this is probably right, but I think
> both this function and the code that I threw off
> in a couple of minutes earlier in the week suffers
> from a deficiency.
>
> As it happens, I need a histogram-match-by-region
> capability. In other words, the user wants to select
> a region in an image, and use the histogram of that
> region to adjust the histogram of the entire image.
>
> This example and my previous code work if the histograms
> are taken from images of the same size. They do not work
> correctly (I think) if the histograms use images of different
> sizes. In that case, you must normalize the histograms to the
> same "total number" of pixels. I'll probably have this on
> my web page soon, with the corrections in it. I just didn't
> want anyone getting too far down the wrong road here. :-)
>
> Cheers,
>
> David
>
>
> --
> David W. Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Phone: 970-221-0438, E-mail: david@dfanning.com
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155




-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Does IDL has histogram matching function?
Next Topic: Re: POLYSHADE-like object graphics?

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

Current Time: Thu Oct 09 20:01:27 PDT 2025

Total time taken to generate the page: 0.00184 seconds