IPB

Welcome Guest ( Log In | Register )

Vignetting, discussion about methods of resolution
Tman
post Aug 24 2005, 07:37 AM
Post #1


Member
***

Group: Members
Posts: 877
Joined: 7-March 05
From: Switzerland
Member No.: 186



Hi Nirgal and all, I would like to discuss about vignetting and methods of resolution for it. I'm mainly interested in mathematical methods that could automatically calculate and adjust the right grey value for each pixel in a single picture.

My current method works with more or less transparent layers over the original picture that so roughly are able to balance the grey values. A perfect layer have to be the exact inverted brightness difference of each picture with this shadow effects. This method is very effective if you get the correct inverted values. These shots of the Mars sky come nearly at such a perfect mask, but not always. And of course the center of the pictures lose much of theirs original brightness/luminance sadly.

I have in mind a mathematical method that can adjust each grey value in a pic in order to obtain a completely balanced brightness over the entire picture. But I'm not in the position to reach that. I only know one have to start with the calculation of the grey values in the center of the picture. In the center are quasi the reference values of the whole picture, if I'm correct.
Is there a possibility (mathematical method) to get (roughly) the same brightness and luminance like in the center over the whole picture from the MERs?

Greetings, Peter


--------------------
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
MichaelT
post Nov 13 2005, 06:17 PM
Post #2


Member
***

Group: Members
Posts: 156
Joined: 18-March 05
From: Germany
Member No.: 211



Hi Michael,

it would indeed be very nice if someone implemented it into MMB. Unfortunately, that won't be me as I do not have experience in Java-programming. I will post the code of my anti-vignetting routine in the next couple of days. So I hope that someone else can transform the code into Java.

Michael
Go to the top of the page
 
+Quote Post
jaredGalen
post Nov 13 2005, 06:49 PM
Post #3


Member
***

Group: Members
Posts: 257
Joined: 18-December 04
Member No.: 123



I would be interested in giving it a go. I made a java attempt at MichaelT's
DD enhancing algorithm before so I fancy a go at this even of some else beats me to it smile.gif
But I think I might need a bit of expansion on parts of the algorithm posted at the start of the thread.

I'm not entirely sure of the different colour spaces.
For example can you convert directly from greyscale to LAB or must it be in RGB.
I have been looking and have found conversion from RGB to XYZ to LAB but not directly
from RGB to LAB.
>>0. convert the image to LAB color space to handle color and luminance independently

And then
>>6. so,as a last step I create a b-spline (or linear) interpolated version of the
correction curve.

In terms of getting the curve and things I'm a bit blink.gif

I'll wait for MichaelT to post his routine I think, but I'll give it a go.


--------------------
Turn the middle side topwise....TOPWISE!!
Go to the top of the page
 
+Quote Post
MichaelT
post Nov 14 2005, 06:12 PM
Post #4


Member
***

Group: Members
Posts: 156
Joined: 18-March 05
From: Germany
Member No.: 211



QUOTE (jaredGalen @ Nov 13 2005, 06:49 PM)
I would be interested in giving it a go. I made a java attempt at MichaelT's
DD enhancing algorithm before so I fancy a go at this even of some else beats me to it smile.gif
But I think I might need a bit of expansion on parts of the algorithm posted at the start of the thread.

I'm not entirely sure of the different colour spaces.
For example can you convert directly from greyscale to LAB or must it be in RGB.
I have been looking and have found conversion from RGB to XYZ to LAB but not directly
from RGB to LAB.
>>0. convert the image to LAB color space to handle color and luminance independently

And then
>>6. so,as a last step I create a b-spline (or linear) interpolated version of the
correction curve.

In terms of getting the curve and things I'm a bit  blink.gif

I'll wait for MichaelT to post his routine I think, but I'll give it a go.
*


Ok, its great that you want to try it biggrin.gif I hope you find the following lines useful. By now I completely skipped using FFT rolleyes.gif. It can just as well be done without.

Concerning LAB etc: I don't know how to convert between the different color spaces. I found that the amount of vignetting in the color images is different between the RGB channels. So I don't know what it would be like if you applied the anti-vignetting to the two color-channels of LAB. Probably that gives some strange results? Don't know.

The other questions are hopefully answered below:

These lines of code are to generate the template function (see below).
First a vector T is generated that is XDIM long (XDIM: the x-dimension of the image) and runs from -pi/2 to +pi/2. The FINDGEN command outputs a vector of length XDIM containing values in ascending order from 0 to XDIM - 1.
EM = COS(T) * 0.1 + 0.9 is used as basis for the template matrix. As you can see it has a cosine shape. As initial value of the vignetting I assume 10%, ie. the factor 0.1. The 0.9 is added so that the maximum value is 1.0 while the minimum is 10% lower.
This vector is filled in a matrix of size (XDIM, XDIM) if XDIM > YDIM otherwise YDIM is used (IF statement).
To obtain a rotation-symmetric matrix, the transpose is added to that matrix and everything devided by two (ES).
To match the size of the image, the unneccessary data are removed (ESS).
To save time, the template is later fitted to a size-reduced image, and, therefore, reduced to the given size using the CONGRID-command. The size then is (512, YDIM*512/XDIM) or (XDIM*512/YDIM, 512) depending on the image (landscape or portrait).

[code begins]

IF XDIM GE YDIM THEN BEGIN
DISX = 512.0
DISY = YDIM * 512.0 / XDIM
T = (FINDGEN(XDIM) * 1.0 * !PI / XDIM -!PI / 2.0)
EM = COS(T) * 0.1 + 0.9
ES1 = {ES11: EM}
ES1 = REPLICATE(ES1, XDIM)
ES = (ES1.ES11 + TRANSPOSE(ES1.ES11)) / 2.0
ESS = ES[*, DIFF: DIFF + YDIM - 1]
ESS2 = CONGRID(ES[*, DIFF: DIFF + YDIM - 1], DISX, DISY)
ENDIF ELSE BEGIN
DISX = XDIM * 512.0 / YDIM
DISY = 512.0
T = (FINDGEN(YDIM) * 1.0 * !PI / YDIM -!PI / 2.0)
EM = COS(T) * 0.1 + 0.9
ES1 = {ES11: EM}
ES1 = REPLICATE(ES1, YDIM)
ES = (ES1.ES11 + TRANSPOSE(ES1.ES11)) / 2.0
ESS = ES[DIFF: DIFF + XDIM - 1, *]
ESS2 = CONGRID(ES[DIFF: DIFF + XDIM - 1, *], DISX, DISY)
ENDELSE

[code ends]

No comes the routine to fit the template to the image. It is rather complicated...
Using an iterative process I try to get as close as possible to the optimal fit. There are likely quicker/better ways to do this.

Firstly, ESS2, the template (see above) is now called E. The aim is to determin a parameter NR so that E^NR optimally fits the image.

First I calculate E^NR for three preset values given in INTR, yielding ESSR. Then I divde the image ( B ) by ESSR, which results in a temporary vignetting reduced image (FP_TEMP_R).
In step two I run through all rows (chosen by the user, actually rows between APY1 and APY2. That allows to do the fitting for parts of the image, eg. the sky, only) of FP_TEMP_R and fit a 2nd-order polynomial to the pixel-values (X is there to provide some x-values for the fit). The parameters of which are stored in RR. If an image is completely without vignetting, I assume that the sum PTR of the squared 2nd-order parameters (RR[2]) is minimal, as the "curvature" of the pixel values caused by the vignetting should be gone.

You might ask now, why I fit a 2nd-order polynomial to the supposed cosine shaped vignetting. Well, I found that the difference is not that large in most cases and that there are ready-to-use IDL routines for the polynomial fit.

As you can see I do this for the three values given in INTR [I1, I2, I3],. After doing so, I look for which of the two values PTR is minimal. I then use these two values from INTR (would be either [I1, I2] or [I2, I3])to define a new INTR with three new values. Two of which are I1 and I2 or I2 and I3 and a value in between the two (actually not quite I1, I2 or I2, I3 as the optimal value might still be in the respective other interval, but close to I2). The whole process then starts again with these new values. That is done a total of 15 times. After that the interval INTR has converged sufficiently close to the optimal value of NR.


[code begins]

E = ESS2

INTR = [0.0D, 15.0D, 30.0D]

X = DINDGEN(DISX) - DISX / 2.0D + 0.5D
RR = FLTARR(3, DISY)
RTR = FLTARR(3)


FOR K = 0, 14 DO BEGIN

FOR J = 0, 2 DO BEGIN

ESSR = E^INTR[J]

FP_TEMP_R = B / ESSR

FOR I = APY1, APY2 - 1, 1 DO BEGIN
WAIT, 0.00001
RR[*, I] = POLY_FIT(X, FP_TEMP_R[*, I], 2)
ENDFOR

RTR[J] = TOTAL(SQRT(RR[2, *]^2))

ENDFOR

SRTR = SORT(ABS(RTR))
INTR = [INTR[SRTR[0]], (INTR[SRTR[0]]+INTR[SRTR[1]]) / 2.0D, INTR[SRTR[1]]]
INTR = INTR[SORT(INTR)]
INTR = [INTR[0] - 0.05D * (INTR[1] - INTR[0]), INTR[1], INTR[2] + 0.05D * (INTR[2] - INTR[1])]

ENDFOR

[code ends]

All that can be done for all three color channels, as the amount of vignetting can be different for red, green and blue. Not for gray-scale images, though.

The code below shows what would be done for a gray-scale jpeg after NR (actually the parameter for the red-channel) has been determined:


[code begins]

NR = INTR[SRTR[0]]
NG = NR
NB = NR

ESST = ESS^NR

CR = CRS / ESST
CG = CGS / ESST
CB = CBS / ESST

[code ends]

Where CRS, CGS and CBS are the original color channels of the image. The new ones are CR, CG and CB.

In my program you can additionally choose howstrong the anti-vignetting is applied, so the final result would by something like:

CR = AV * CRS / ESST + (1 - AV) * CRS
etc., with AV between 0 and 1 (actually AV< 1 would be/is possible).

But I think this part is the most interesting for you jaredGalen. Most important is, I think, that the determination of the amount of vignetting can be done with a size reduced image. The found parameter can then be used for the original image. That saves a lot of time smile.gif

The complete program can be found here

Unfortunately, I did not have time to comment it very much. I know, this is bad ph34r.gif

Any other questions rolleyes.gif

Michael
Go to the top of the page
 
+Quote Post

Posts in this topic
- Tman   Vignetting   Aug 24 2005, 07:37 AM
- - Nirgal   Hi Tman, mathematically, we can describe vignetti...   Aug 24 2005, 11:29 PM
- - Tman   Hi Nirgal, probably you're right and it's ...   Aug 25 2005, 11:26 AM
|- - Nirgal   Thanks Micheal, hopefully I will find the time to...   Aug 25 2005, 08:46 PM
|- - Tman   QUOTE (Nirgal @ Aug 25 2005, 10:46 PM)...no n...   Aug 25 2005, 09:29 PM
|- - Tesheiner   QUOTE (Tman @ Aug 25 2005, 11:29 PM)Guess I...   Aug 26 2005, 06:42 AM
- - MichaelT   Hi Tman, I tried it using "Fast Fourier Tran...   Aug 25 2005, 12:42 PM
- - Tman   Hi Michael, best we would talk about it in German,...   Aug 25 2005, 02:17 PM
|- - MichaelT   QUOTE (Tman @ Aug 25 2005, 02:17 PM)Hi Michae...   Aug 25 2005, 04:39 PM
|- - Nirgal   QUOTE (MichaelT @ Aug 25 2005, 06:39 PM)Proba...   Aug 25 2005, 05:16 PM
|- - MichaelT   QUOTE (Nirgal @ Aug 25 2005, 05:16 PM)Hi Mich...   Aug 25 2005, 05:59 PM
- - Tman   Yeah sounds really good so far That would be fant...   Aug 25 2005, 08:38 PM
- - MichaelT   Nirgal, I finished the commenting of my program to...   Aug 26 2005, 05:57 PM
- - MichaelT   I have now modified the anti-vignetting-program (u...   Sep 14 2005, 05:49 PM
|- - dilo   WOW! MichaelT, I think would be really GREAT t...   Sep 14 2005, 06:38 PM
||- - mhoward   QUOTE (dilo @ Sep 14 2005, 06:38 PM)WOW! ...   Nov 11 2005, 04:09 PM
||- - dilo   QUOTE (mhoward @ Nov 11 2005, 04:09 PM)If the...   Nov 13 2005, 08:02 AM
|- - Bob Shaw   MichaelT: Do you think your anti-vignetting app c...   Sep 14 2005, 06:53 PM
|- - MichaelT   QUOTE (Bob Shaw @ Sep 14 2005, 06:53 PM)Micha...   Sep 14 2005, 07:39 PM
|- - Bob Shaw   QUOTE (MichaelT @ Sep 14 2005, 08:39 PM)Bob, ...   Sep 14 2005, 08:43 PM
- - djellison   I'm guessing there's no flatfield or darkf...   Sep 14 2005, 07:03 PM
|- - tedstryk   I usually try to make a blank image with my digita...   Sep 14 2005, 07:32 PM
- - MichaelT   Hi, I put an updated version of the anti-vignetti...   Oct 24 2005, 04:30 PM
|- - Tesheiner   QUOTE (MichaelT @ Oct 24 2005, 06:30 PM)Anywa...   Nov 1 2005, 02:25 PM
- - jvandriel   Tman, what I mean to say with those lines is the ...   Nov 1 2005, 10:31 AM
- - Tman   You're right Jvandriel, it's for both very...   Nov 1 2005, 11:59 AM
- - djellison   I dont mind it running in IDL, but I would really ...   Nov 1 2005, 04:00 PM
- - MichaelT   QUOTE (djellison @ Nov 1 2005, 04:00 PM)I don...   Nov 1 2005, 04:22 PM
- - MichaelT   I just put online Version 2.0, now with batch proc...   Nov 1 2005, 05:45 PM
- - Tman   Hi Michael, Tried the batch processing just with ...   Nov 1 2005, 06:58 PM
- - jvandriel   Michael T, today I used for the first time your a...   Nov 3 2005, 03:20 PM
- - Nix   I'm starting to use your tool too, looks prett...   Nov 3 2005, 07:12 PM
- - MichaelT   Hi Michael, it would indeed be very nice if someo...   Nov 13 2005, 06:17 PM
|- - jaredGalen   I would be interested in giving it a go. I made a ...   Nov 13 2005, 06:49 PM
|- - MichaelT   QUOTE (jaredGalen @ Nov 13 2005, 06:49 PM)I w...   Nov 14 2005, 06:12 PM
|- - jaredGalen   Wow, okay. Looks like I have my work cut out for ...   Nov 14 2005, 06:33 PM
- - slinted   Michael, thank you for sharing the code to this ap...   Nov 14 2005, 11:15 PM
|- - jaredGalen   QUOTE (slinted @ Nov 15 2005, 12:15 AM)Jared,...   Nov 15 2005, 09:05 AM
- - jamescanvin   How long does this program take to run for you guy...   Nov 15 2005, 02:50 AM
|- - MichaelT   QUOTE (jamescanvin @ Nov 15 2005, 02:50 AM)Ho...   Nov 15 2005, 10:04 AM
- - Tman   The same to me - 5 seconds. My PC system runs 2,4...   Nov 15 2005, 10:51 AM
- - jamescanvin   Hmm, 5 seconds eh, that's a bit quicker than 5...   Nov 15 2005, 01:34 PM
- - Nix   no mac, but 3 seconds, although it might well be a...   Nov 15 2005, 05:28 PM
|- - jamescanvin   QUOTE (NIX @ Nov 16 2005, 04:28 AM)Hope you f...   Nov 15 2005, 11:13 PM
- - MichaelT   I made a minor modification to the program. I don...   Nov 16 2005, 08:47 AM
|- - jaredGalen   Hi, I haven't a much of a chance to do any cod...   Nov 16 2005, 01:38 PM
||- - MichaelT   QUOTE (jaredGalen @ Nov 16 2005, 01:38 PM)Hi,...   Nov 16 2005, 03:12 PM
||- - Nirgal   Micheal, I just like to say thank you for sharing...   Nov 16 2005, 08:36 PM
||- - MichaelT   QUOTE (Nirgal @ Nov 16 2005, 08:36 PM)Micheal...   Nov 17 2005, 08:45 PM
|- - jamescanvin   QUOTE (MichaelT @ Nov 16 2005, 07:47 PM)I mad...   Nov 17 2005, 03:10 AM
|- - jamescanvin   QUOTE (MichaelT @ Nov 16 2005, 07:47 PM)I mad...   Nov 19 2005, 02:43 AM
|- - MichaelT   QUOTE (jamescanvin @ Nov 19 2005, 02:43 AM)It...   Nov 19 2005, 08:05 AM
- - jvandriel   MichaelT, I just downloaded Anti_Vig 2.0.1, but w...   Nov 18 2005, 12:41 PM
|- - MichaelT   QUOTE (jvandriel @ Nov 18 2005, 12:41 PM)Mich...   Nov 18 2005, 01:49 PM
- - Tman   Hi Jvandriel, I guess you renamed it as "Ant...   Nov 18 2005, 01:44 PM
|- - MichaelT   QUOTE (Tman @ Nov 18 2005, 01:44 PM)Hi Jvandr...   Nov 18 2005, 01:54 PM
- - MichaelT   Would you like me to include the version number in...   Nov 18 2005, 02:04 PM
- - Tman   Hi Michael, just reply overlap. Regarding version...   Nov 18 2005, 02:09 PM
- - jvandriel   MichaelT and Tman, thanks for the advice. I did i...   Nov 19 2005, 02:04 PM
|- - MichaelT   QUOTE (jvandriel @ Nov 19 2005, 02:04 PM)is i...   Nov 24 2005, 05:40 PM
- - MichaelT   After a long, long time I am currently developing ...   May 5 2006, 11:46 AM
|- - hortonheardawho   Hi Michael, I have been interested in your anti-v...   Jun 9 2006, 10:16 PM
- - hortonheardawho   Doesn't look like Michael is monitoring this t...   Jun 11 2006, 07:58 PM
|- - MichaelT   QUOTE (hortonheardawho @ Jun 11 2006, 07...   Jun 12 2006, 05:12 PM
- - DonPMitchell   Very cool work, Michael. I know in a mathematical...   Jun 12 2006, 06:07 PM
|- - Airbag   QUOTE (DonPMitchell @ Jun 12 2006, 02:07 ...   Jun 13 2006, 02:47 AM
||- - helvick   QUOTE (Airbag @ Jun 13 2006, 03:47 AM) Th...   Jun 13 2006, 12:53 PM
|- - MichaelT   QUOTE (DonPMitchell @ Jun 12 2006, 06:07 ...   Jun 14 2006, 05:06 PM
|- - DonPMitchell   If they measured the camera response, then that is...   Jun 14 2006, 05:42 PM
- - jrdahlman   Is this anti-vignetting program specifically for M...   Jun 29 2006, 07:43 PM
|- - MichaelT   QUOTE (jrdahlman @ Jun 29 2006, 07:43 PM)...   Jul 3 2006, 06:03 PM
- - edstrick   The Voyager (mariners, viking) cameras have other ...   Jul 4 2006, 09:51 AM
- - jrdahlman   Sorry for the delay. My website requires me to upl...   Jul 5 2006, 04:47 PM
|- - MichaelT   QUOTE (jrdahlman @ Jul 5 2006, 04:47 PM) ...   Jul 6 2006, 12:37 PM
|- - ugordan   QUOTE (jrdahlman @ Jul 5 2006, 05:47 PM) ...   Jul 6 2006, 01:01 PM
|- - MichaelT   QUOTE (jrdahlman @ Jul 5 2006, 04:47 PM) ...   Jul 6 2006, 05:59 PM
- - um3k   Another problem is that Voyager images exhibit a l...   Jul 6 2006, 01:49 PM
- - um3k   jrdahlman, these websites may come in handy for yo...   Jul 6 2006, 08:06 PM
- - jrdahlman   Oh, I know that you can download all the images. I...   Jul 6 2006, 08:59 PM
|- - um3k   QUOTE (jrdahlman @ Jul 6 2006, 04:59 PM) ...   Jul 7 2006, 12:57 AM
- - edstrick   Playing with Voyager 1 wide angle images, I found ...   Jul 7 2006, 11:37 AM
- - jrdahlman   I would like to point out that the program um3k...   Jul 10 2006, 06:19 AM
- - edstrick   Dark current images are those taken with zero expo...   Jul 10 2006, 09:42 AM


Reply to this topicStart new topic

 



RSS Lo-Fi Version Time is now: 1st November 2024 - 12:05 AM
RULES AND GUIDELINES
Please read the Forum Rules and Guidelines before posting.

IMAGE COPYRIGHT
Images posted on UnmannedSpaceflight.com may be copyrighted. Do not reproduce without permission. Read here for further information on space images and copyright.

OPINIONS AND MODERATION
Opinions expressed on UnmannedSpaceflight.com are those of the individual posters and do not necessarily reflect the opinions of UnmannedSpaceflight.com or The Planetary Society. The all-volunteer UnmannedSpaceflight.com moderation team is wholly independent of The Planetary Society. The Planetary Society has no influence over decisions made by the UnmannedSpaceflight.com moderators.
SUPPORT THE FORUM
Unmannedspaceflight.com is funded by the Planetary Society. Please consider supporting our work and many other projects by donating to the Society or becoming a member.