4

The objective of the following code is to plot SNR of RGB image(well,the code illustrated id for gray scale since I could not do for RGB which is the ultimate goal) and y axix plots the mean error between clean and noisy image divided by the standard deviation of the clean image (in order to scale the error). The code generates error

??? Subscript indices must either be real positive
integers or logicals.

Error in ==> cr_t at 34

varra=var(var(CleanImg_normalized)); 
  1. Please help with the corrected code since I am getting a single value a dot as a plot instead of a line plot
  2. How to modify the code for RGB images
  3. Is there any significane of the integer number multipled for calculating SNR in db,I have seen 10,20 numbers most popularly used.
Cœur
  • 37,241
  • 25
  • 195
  • 267
user1142671
  • 115
  • 1
  • 13
  • The error seems to suggest that `var` is an array, rather than the built in function which calculates the variance. Have you defined `var` as a variable elsewhere in your scope/workspace? – Chris Jan 11 '12 at 09:48
  • Also, there is a typo in line 4 above, where you refer to 'CleanIm' instead of 'CleanImg'. Maybe some predefined CleanIm is causing some problems? Also, why are you wanting to plot a single point? Is this part of an attempt to clean up the image? – Vidar Jan 11 '12 at 10:11
  • @Vidar:Thank you for the reply.That error is no longer there,i just restarted my machine.And yes,the plot is a single point instead of a line plot!Why is that?I wanted to plot SNR vs mean error scaled by the variance of the clean image.How do I go about it? – user1142671 Jan 11 '12 at 18:12
  • Also see [this question](http://stackoverflow.com/questions/20054047/subscript-indices-must-either-be-real-positive-integers-or-logicals-generic-sol) for [the generic solution to this problem](http://stackoverflow.com/a/20054048/983722). – Dennis Jaheruddin Nov 27 '13 at 15:49

1 Answers1

6

As said by @Chris, according to your error message, it seems like matlab believe that var is a variable. So maybe you have already assigned this variable. To check that do:

whos var

If the output is not empty it means that indeed var is assigned.

In that case, do:

clear var

After that the variable var should not be assigned any more. So run again your script. However you should also check that var is not assigned during your script.

Oli
  • 15,935
  • 7
  • 50
  • 66
  • :The error is gone,i just restarted my machine and variance var variable was not assigned anywhere else.However,for plot it just gives a dot as a plot instead of a line plot!The values are SNR = 0.9786 varra = 4.7182e-005 .Dont know what went wrong logically now.Please help. – user1142671 Jan 11 '12 at 18:00