From: Bufoss on 8 Jun 2010 10:59 Hi, I need your help in image processing in matlab. I have an image Rose size 256*256*3, an indexedRose size 256*256 and a paletteRose(RGB) size 4 * 3. I want to compute the mse (mean square error). Could you help me ? My code is [code] main.m [MseRose] = MseCompute(Rose,indexedRose); [/code] [code] MseCompute.m function [MSE] = MseCompute(image1,image2) MSE = sum( sum((image1 - image2).^2)); MSE = MSE/(size(image1, 1)* size(image2, 2)); end [/code] But I take error MSE = sum( sum((Rose - indexedRose).^2)); ??? Error using ==> minus Integers can only be combined with integers of the same class, or scalar doubles. Could you help me ? Thanks a lot
From: Walter Roberson on 8 Jun 2010 15:29 Bufoss wrote: > I need your help in image processing in matlab. > > I have an image Rose size 256*256*3, > an indexedRose size 256*256 and > a paletteRose(RGB) size 4 * 3. > > I want to compute the mse (mean square error). > Could you help me ? > > My code is > > [code] > main.m > [MseRose] = MseCompute(Rose,indexedRose); > [/code] > > [code] > MseCompute.m > function [MSE] = MseCompute(image1,image2) > MSE = sum( sum((image1 - image2).^2)); > MSE = MSE/(size(image1, 1)* size(image2, 2)); > end > [/code] > > But I take error > MSE = sum( sum((Rose - indexedRose).^2)); > ??? Error using ==> minus > Integers can only be combined with integers of the same class, or scalar doubles. > > Could you help me ? Examine the data types of Rose and indexedRose . You will probably find that they are different integer classes. Even if they were not different classes, you will have difficulty because Rose is an RGB image and you are trying to subtract an indexed image from that. In order to come up with a meaningful computation, you will have to convert the indexed image to RGB, which will require that you know the colormap of the indexed image and use ind2rgb(). You will also have to adjust the code to work in three dimensions. Converting the RGB image to indexed will give you a meaningless computation, as you would be calculating the mse of the _indices_ rather than of the image content.
From: Bufoss on 8 Jun 2010 12:38 Thank you very much for your answer. So, the solution is something like that ? INDEXED4 = ind2rgb(indexedRose4,paletteRose4); INDEXED4 = uint8(INDEXED4); [MSE4] = MseCompute(Rose,INDEXED4); function [MSE] = MseCompute(image1,image2) MSE = sum(sum( sum((image1 - image2).^2))); MSE = MSE/(size(image1, 1)* size(image2, 2)); end I don't know what value I have to expect. the value I take is 91.9763 (quite big I think).
|
Pages: 1 Prev: label each stem on a stem plot Next: Changing contrast of an background rgb image |