Author Topic: how to add a constant to a single column or row  (Read 3912 times)

Offline tkhan

  • Newcomer
  • Posts: 8
how to add a constant to a single column or row
« on: 2013 February 26 10:59:27 »
Need help in adding a constant to a column say 1800,y using Pixel math...not sure how to go about this. purpose is to correct 2-3 adjacent columns in the center of the frame. The data is there but the offset is not linear (like a bad column although not by manufactures definition).

Thanks, Tim




Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: how to add a constant to a single column or row
« Reply #1 on: 2013 February 26 11:44:43 »
Use something like this:
Code: [Select]
iif ( XPos() == 100 , $T+0.5,$T)
PixelMath uses only normalized pixel values (i.e. 0 is black, 1 is white).
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline tkhan

  • Newcomer
  • Posts: 8
Re: how to add a constant to a single column or row
« Reply #2 on: 2013 February 27 08:33:24 »
Thanks Carlos, that worked...but finding the number is not so trivial to make the correct adjustments.

The problem is that I have 3 columns in the center that have strong values in the bias and darks, but not in the flats due to an electric field non linear decay and cannot be calibrated out. The electric field decay only changes the offset in these columns not the data captured. The corrective measure which is now confirmed with your help is to add a constant to the columns, thus not destroying any data or manufacturing new data with pixel repair. But how to determine that number? Well, I have an idea as I will explain:

In my case, the culprit columns are 2203, 2204 and 2205.
so I manually entered the code, iif ( XPos() == 2203 , $T+0.0002,$T) and kept on adding values until the column was indistinguishable from the good calibrated adjacent columns 2202. then moved to 2204 and 2205. Its a very cumbersome process.

The idea is to look at the average value of the adjacent good column 2202 and subtract from the average of the bad column 2203 (only using a target background  values and avoiding hot pixels & stars) and add the offset to the bad column 2203. Now 2203 is corrected and should blend in with the background and become indistinguishable.

Then do similar with bad column 2205 and good column 2206, and adjust offset of 2205, then do the center column 2204 using corrected 2203 and 2205 columns.

So in short, correct the outer 2 columns with adjacent good columns and then the inner column.

For a 2 column problem just eliminate the center column.

So for now I need to test this with code that can correct say the left column, 2203.

Thanks,

Tim

Offline tkhan

  • Newcomer
  • Posts: 8
Re: how to add a constant to a single column or row
« Reply #3 on: 2013 February 27 08:37:45 »
one side note, the sensor is not bad as per the definition by the manufacturer. In fact, for terrestrial images (images with high levels), these columns are unseen. They only show up under stretching astro images.

Tim

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: how to add a constant to a single column or row
« Reply #4 on: 2013 February 27 09:03:57 »
I think that a javascript code would be easier than a PixelMath expression. What I would do is just calculate the median value of those 5 columns (3 bad ones, and the good ones at each side). Then, subtract the median for each respective bad column, and add the median for the adyacent column. For the central one, you may average the medians at each side.
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com

Offline oldwexi

  • PixInsight Guru
  • ****
  • Posts: 627
    • Astronomy Pages G.W.
Re: how to add a constant to a single column or row
« Reply #5 on: 2013 February 27 09:50:23 »
Hi Tim!
Another way could be to use PixelMath to create a ColumnMask
iff(xpos() == 2203, 1, 0) 
Check the "create new image" box and you will get a mask where
everything is set to black except the requested column which will be set to white.

This mask i would lay over the original image and than
use a Histogramm stretch (the forbidden one) with
the right triangle woving it to the left. Switching on STF and
Using RealTimePreview you can see live during moving the
right triangle how the brightness increases linear in the column until it fits.

Running a subtraction with PixelMath of "before and after"
gets you the factor if you are interested in.

Hope i understood your column issue right.

Gerald

Offline Geoff

  • PixInsight Padawan
  • ****
  • Posts: 908
Re: how to add a constant to a single column or row
« Reply #6 on: 2013 February 28 01:00:00 »
There is also a script described here http://www.pixinsight.com/examples/index.html by Juan and Vicent.  Look in the example on NGC 5189 from Gemini Observatory South: Deconvolution and HDRWaveletTransform in PixInsight.  The script takes a bad row or column, and replaces it with values from an adjacent good column and then applies a smoothing filter.  It works very well on the example they give, but I haven't tried it myself, although it's on the to-do list.
Geoff
Don't panic! (Douglas Adams)
Astrobin page at http://www.astrobin.com/users/Geoff/
Webpage (under construction) http://geoffsastro.smugmug.com/

Offline Carlos Milovic

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2172
  • Join the dark side... we have cookies
    • http://www.astrophoto.cl
Re: how to add a constant to a single column or row
« Reply #7 on: 2013 February 28 08:15:00 »
I think that the problem is not that the data is corrupted. It is just a pedestal difference. So, removing it it the way to go, instead of discarding the whole columns.
Regards,

Carlos Milovic F.
--------------------------------
PixInsight Project Developer
http://www.pixinsight.com