1 registered members (AndrewAMD),
831
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Image Deconvolution/"Sharpening"
#373130
06/07/11 19:38
06/07/11 19:38
|
Joined: Jan 2003
Posts: 4,615 Cambridge
Joey
OP
Expert
|
OP
Expert
Joined: Jan 2003
Posts: 4,615
Cambridge
|
Hey folks, I thought I could annoy you with another of my more or less brilliant ideas. I won't bother you with the mathematical details this time, though, and just present you some result. Maybe someone is interested. 1) first line are blurred with a gaussian filter, radius 5,9 and 17, the next three rows show the blurred image after my deconvolution filter was applied to it n times (n=1,10 and 100). this filter is some kind of "brute force" approach. 2) going to frequency space, a mathematically way more elegant approach. note that the image is only reconstructible because there is no noise present. also, it has 16 bit depth. 3) frequency space, this time downsampled to 8 bit (introducing noise). so this would definately be a real world example and possible with my filter. I know I know I should stop posting stuff like that here... well. But I had these images anyway. Joey
|
|
|
Re: Image Deconvolution/"Sharpening"
[Re: Hummel]
#373135
06/07/11 20:08
06/07/11 20:08
|
Joined: Jan 2003
Posts: 4,615 Cambridge
Joey
OP
Expert
|
OP
Expert
Joined: Jan 2003
Posts: 4,615
Cambridge
|
rescaling wouldn't work as the filter can only reconstruct information that has formerly been present. I got the idea when doing an astronomy course, using a telescope's point spread function to estimate what the stars looked like before they passed the optics. Convolution in fourier space is a multiplication, thus "undoing" it can be acheived by simply dividing out the convolution. So the process is Image --FT--> Spectrum Spectrum/=Convolution Kernel --FT--> Reconstructed Image As I know the point spread function (the gaussian matrix used for smoothing it in first place) this process is really easily done, you can look up "Wiener filter" on Wikipedia if you're familiar with some analysis: http://en.wikipedia.org/wiki/Wiener_deconvolutionAs I said, noise makes the thing way more difficult, that's where the ringing effects in the first pictures come from. The first images don't go through fourier transformation, so I need to iterate an estimate. The algorithm is known as "Richardson-Lucy" for those who are interested in it. There's also something called "blind deconvolution", which tries to estimate the psf from the source material itself. For stars it's pretty straightforward, since you "know" their shapes. I haven't found out how to do it properly for a normal image, though.
|
|
|
Re: Image Deconvolution/"Sharpening"
[Re: Hummel]
#373144
06/07/11 20:30
06/07/11 20:30
|
Joined: Jan 2003
Posts: 4,615 Cambridge
Joey
OP
Expert
|
OP
Expert
Joined: Jan 2003
Posts: 4,615
Cambridge
|
No, I can post it here, my notebooks are a mess anyway . 1st one
normalize[mat_] := mat/Total[Total[mat]];
deconv[i0_, k_, n_, count_] :=
Module[{i = i0},
Do[i = ImageAdd[i0,
ImageConvolve[i,
normalize[BoxMatrix[0, 2*n + 1]] - normalize[k[n]]]], {count}];
i
];
source = Import["ExampleData/lena.tif"];
g0 = ImageConvolve[source, normalize[BoxMatrix[1]]]
deconv[g0, BoxMatrix, 1, 10]
2nd one
size = 128;
imagesize = size*2 + 1;
total[mat_] := Total[Total[mat]];
normalize[mat_] := mat/total[mat];
(* load data, make ft, inverse ft *)
image = ImageResize[ExampleData[{"TestImage", "Lena"}], imagesize]
data = ImageData[image];
col = First[ImageDimensions[image]]
row = Last[ImageDimensions[image]]
px = col*row;
f = Partition[Take[Flatten[data], {2, px*3, 3}], col];
fourier = Fourier[f, FourierParameters -> {0, 1}];
intensity = total[f];
Image[Abs[
RotateRight[fourier, {IntegerPart[row/2], IntegerPart[col/2]}]]]
Image[Abs[InverseFourier[fourier]]]
(* load convolution kernel in fs *)
blurfunction =
RotateRight[
Transpose[RotateRight[GaussianMatrix[{size, 30}], size]], size];
ListPlot3D[blurfunction, PlotRange -> All]
(*blur image, comparison with original*)
resetIntensity[mat_] := normalize[mat]*intensity;
blurred = fourier*blurfunction;
blurredImage = Image[resetIntensity[
Abs[InverseFourier[blurred]]
]]
(*undo blur*)
reconstructed = blurred/blurfunction;
Image[resetIntensity[
Abs[InverseFourier[reconstructed]]
]]
I hope the code works. It relies quite a bit on the mathematica stuff but it should be no problem to do it in another language.
|
|
|
Re: Image Deconvolution/"Sharpening"
[Re: Joey]
#373167
06/07/11 22:30
06/07/11 22:30
|
Joined: Oct 2006
Posts: 873
Shadow969
User
|
User
Joined: Oct 2006
Posts: 873
|
really interesting stuff, too bad i can't study the subject in depth atm. however, it would be nice if you could take your time to answer a couple of questions that i came up with at the first glance -are there any methods for reconstruction without any a priori knowledge about the convolution kernel? -have you tried measuring source and blurred images' entropy and\or other information parameters? (although i'm pretty sure that they'll be the same) -how fast does this method degradate with appearance of noise?
|
|
|
|