1
votes

If this be the formula for MSE for RGB images A,B of same size 256*200, then how to obtain a line plot for every pixel with x axis representing pixels and y axis representing the MSE values

MSE = reshape(mean(mean((double(A) - double(B)).^2,2),1),[1,3])

There are only two images A ,B. The plot should illustrate change between each pixel of A and B which is meant by MSE.

1
What do you mean by "number of pixels"? Do you actually have a series of differently-sized pairs of images, or what? I think you need to explain more about your problem before we can do much to help you solve it.Gareth McCaughan
@Gareth: Edited the question as suggested.Sm1
So are you looking for a plot that has 256*200 points, one for every pixel of the image (in, let's say, raster order)? Or one with one point per image row (or per image column) showing mean-squared errors for individual rows/columns? Or something that's ordered by amount of error, showing the statistical distribution of errors? Sorry to pester, but it's still not at all clear to me what you're after...Gareth McCaughan
@Gareth : No problem with your queries , after all I should be the one apologizing. The first option sounds ok. The plot should be for MSE vs pixels so that I should be able to see the error pattern(one point per image row (one for every pixel of the image).Sm1
I don't understand your last comment. First you say "The first option sounds OK" -- that was the one with one data point per pixel. Then you say "one point per image row", which is something else entirely. Then you say "one for every pixel of the image" again. And if you really plot a point for every pixel, your plot isn't showing mean squared errors any more anyway! At least one of us is confused...Gareth McCaughan

1 Answers

1
votes

If you want to display the changes "between each pixel" then what you're showing is not mean squared errors any more -- there's no averaging going on. (Unless you intend to average across the three colour planes, but I don't recommend that: changes in R,G,B are not equally salient to the human visual system. If you really must do this, you might want to weight them, say, 2:4:1 for something a bit more representative, but this is still ad hoc and not likely to give a very accurate idea of what differences will look biggest.)

Of course it's perfectly reasonable to want to see the per-pixel errors, but I wouldn't recommend using a line plot to display them; it's likely to be confusing rather than informative. Rather, display them as an image:

errs = (double(A)-double(B)).^2;
image(errs / max(errs(:)));
axis image;

which you can then compare by eye with A and B to see what image regions/features/... correspond to worse errors. The brightness and colour of each pixel indicate the amount of error and how it's distributed across the R, G, and B planes.

On the other hand, perhaps what you actually need is mean squared error over individual rows, or columns, of the image. In that case, after creating errs as above, use mean to compute the row or column means; that will give you a 256-by-1-by-3 image or a 1-by-200-by-3 image; now I would suggest plotting R,G,B curves separately unless you (probably foolishly in my opinion, as mentioned above) insist on averaging the planes.

row_errs = mean(errs,2); % this is now of size [n,1,3]

now row_errs(:,:,1) is a vector of MS-across-rows red errors, row_errs(:,:,2) is a vector of MS-across-rows green errors, etc. You can feed these to plot.