Message Boards Message Boards

0
|
1812 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

Image distance between noisy and clean images

Posted 1 year ago

This is what I am trying to do:

Download MNIST images:

resource = ResourceObject["MNIST"];
trainingData = ResourceData[resource, "TrainingData"];
testData = ResourceData[resource, "TestData"];
SeedRandom[42];
rctraindata = RandomChoice[trainingData, 1000];
rctraindatat = 1. - Map[Flatten, Map[ImageData, rctraindata[[All, 1]]]];

Add Guassian noise:

nrctraindatat = Table[rctraindatat[[i]] + RandomVariate[NormalDistribution[0, 0.2], 784], {i, Length[rctraindatat]}];

Calculate the distance between clean and noisy image:

EuclideanDistance[rctraindatat[[1]], nrctraindatat[[1]]] (*5.82*)

Scale the noisy image as follows:

scaled = (nrctraindatat[[1]]-Min[Flatten[nrctraindatat]])/(Max[Flatten[nrctraindatat]] - 
     Min[Flatten[nrctraindatat]]);

The idea behind scaling is that the clean images are within (0,1) and I wanted the noisy image to be in the same range to calculate the distance between them. Calculate the distance again:

EuclideanDistance[rctraindatat[[1]], scaled] (*8.78*)

Which is the correct way to calculate the distance between a corrupted and a clean image and why? PSNR and SSIM are usually used as metrics. Do I need to rescale the noisy image before calculating PSNR or SSIM?

I also posted here

POSTED BY: Psi Meson

The euclidean distance between two vectors is

d[x_,y_]:= Sqrt[  Total[(x-y)^2]  ]

For a disturbation W with mean 0 and standard deviation 1

Y = X + sigma  W

the distance is obviously

d[ X , Y] = sigma Sqrt[ Total[ W ^ 2] ] = sigma Sqrt[ Lenght[W]] Sqrt[Mean[W ^2]]

It follows if W is a NormalDistribution[0,1] the distance is

d[ X , Y] = sigma  Sqrt[  Total[ W ^ 2]  ]  = sigma  Sqrt[ Lenght[W]] 

Since you are working with a sigma = 0.2 and Length[W]=784 you will find a value near 0.2 * 28 = 5.6

POSTED BY: Roland Franzius
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract