Welcome to iraf.net Wednesday, May 01 2024 @ 09:52 AM GMT


 Forum Index > Help Desk > Applications New Topic Post Reply
 Correcting Row Offsets?
   
joshw
 01/29/2006 10:23PM (Read 6398 times)  
++---
Junior

Status: offline


Registered: 12/09/2005
Posts: 26
I've got some images which suffer from time variable noise which offsets each row of pixels by a small amount from the rows above and below it. The noise can be corrected in most cases by adding a small offset to each row such that the median of the row matches the median of the entire image. I've written a script to do this in IDL and it works beautifully, but I am looking for a way to do this in IRAF so that I can keep all my reductions in one script rather than jumping back and forth between IRAF and IDL.Does anyone know of a clever way to do this? I've been looking for the right type of filter for it, but so far I haven't found anything that works nearly as well as my simple IDL routine.thanks,
Josh

 
Profile Email Website
 Quote
fitz
 01/29/2006 10:23PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
If I understand your problem correctly, to each row you want to add something like the difference between the median of the row and the median of the entire image, right? Not quite a one-liner but try real im_mean
imstat (oldimage, fields="midpt", format-) | scan (im_mean)
imexpr ("a + (b - median(a))", newimage, a=oldimage, b=im_mean)In the expression 'a' is processed for each line in the image, '(b-median(a))' is a scalar value that's the offset I think you're looking for. See the help pages for IMSTAT and IMEXPR for details.Cheers,
-Mike

 
Profile Email
 Quote
joshw
 01/29/2006 10:23PM  
++---
Junior

Status: offline


Registered: 12/09/2005
Posts: 26
If 'a' is processed for each line of the image, don't I need some kind of loop to run through each line? If so, how do I specify the appropriate image section within the loop?-Josh

 
Profile Email Website
 Quote
fitz
 01/29/2006 10:23PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
IMEXPR loops through the image rows automatically. What I means is that
'a' (in this case) is a vector operand containing all the pixels in a row of
the image, the expression is repeated/re-evaluated for each row. If you want
to operate on only a few rows then you can just tack the section onto the image name when you call it, or see the use of the I/J/K builtins for using the row/col/band number in the expression.-Mike

 
Profile Email
 Quote
joshw
 01/29/2006 10:23PM  
++---
Junior

Status: offline


Registered: 12/09/2005
Posts: 26
Sorry for dragging this on, but I'm still having trouble. Here is the code as I'm running it. I'm operating on image test1.fits and hoping to output the result to test2.fits:real im_mean
imstat ("test1", fields="midpt", format-) | scan (im_mean)
imexpr ("a + (b - median(a)", "test2", a="test1", b=im_mean) I get the following error after running the imexpr line:
ERROR: ambiguous parameter `a' within `<searchpath>'Also, I still don't understand how this is looping though the rows of the image. Did I just get lucky and imexpr naturally loops through rows? Would this be different if I had to operate on columns?thanks,
Josh

 
Profile Email Website
 Quote
fitz
 01/29/2006 10:23PM  
AAAAA
Admin

Status: offline


Registered: 09/30/2005
Posts: 4040
[quote:f768448c86]real im_mean
imstat ("test1", fields="midpt", format-) | scan (im_mean)
imexpr ("a + (b - median(a)", "test2", a="test1", b=im_mean)
[/quote:f768448c86]
Note there is a missing closed paren in your expression.[quote:f768448c86]I get the following error after running the imexpr line:
ERROR: ambiguous parameter `a' within `<searchpath>'
[/quote:f768448c86]
The syntax above is the normal script 'program mode', the error message sometimes happens due to quirks in the CL and can usually be cleared by declaring a dummy parameter 'a' to avoid the message, e.g. string a
real im_mean
:[quote:f768448c86]Also, I still don't understand how this is looping though the rows of the image. Did I just get lucky and imexpr naturally loops through rows? Would this be different if I had to operate on columns? [/quote:f768448c86] Right, the task is meant to apply the expression to the entire image, it does so one-row at a time. If you wanted to work on columns I suppose you could simply IMTRANSPOSE the image before/after IMEXPR or loop using an image section.-Mike

 
Profile Email
 Quote
joshw
 01/29/2006 10:23PM  
++---
Junior

Status: offline


Registered: 12/09/2005
Posts: 26
That worked perfectly once I cleared the a and b parameters. Thanks!Josh

 
Profile Email Website
 Quote
   
Content generated in: 0.24 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Filtered HTML Allowed 
Censored Content 
dog allergies remedies cialis 20 mg chilblain remedies


Privacy Policy
Terms of Use

User Functions

Login