You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
why following error is appearing when i use other image
1 view (last 30 days)
Show older comments
Error using vertcat Dimensions of matrices being concatenated are not consistent.
15 Comments
Geoff Hayes
on 3 Apr 2018
Komal - please copy and paste the full error message that should include which line of code is throwing the error. And is the other image the one that you have attached? Remember, we can't easily run your GUI since you have not included the figure file nor have you outlined the steps that you have followed which generates the error.
Komal Gaikwad
on 4 Apr 2018
Edited: Walter Roberson
on 5 Apr 2018
sir i am attaching the fig file:
Steps are as follows
1.run the code, after GUI is opened select image (i have used attached cameraman.jpg image, but if lena.jpg image is used no error is coming) after that add noise in the given box , next is click on noisy image. After the noisy image is displayed when i click on filtered image it is showing me the error as follows-->
"Error using vertcat
Dimensions of matrices being concatenated are not consistent.
Error in maingui1>fltimg_Callback (line 155)
p_im_n= [ zeros(ln,im_sz(2)) ; im_n; zeros(ln,im_sz(2))]; %%%%%%%%error showing here%%%%%
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in maingui1 (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)maingui1('fltimg_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback"
Geoff Hayes
on 4 Apr 2018
The error message from the line
p_im_n= [ zeros(ln,im_sz(2)) ; im_n ; zeros(ln,im_sz(2))];
is telling you that the dimensions of the matrices that you are trying to concatenate are invalid. Since the error is for a vertical concatenation, this suggests that the columns of one or more of your matrices are invalid. I would put a breakpoint at this line and re-run your code. Look at the dimensions (rows and columns) for
zeros(ln,im_sz(2))
im_n
zeros(ln,im_sz(2))
Do all three have the same number of columns?
Komal Gaikwad
on 5 Apr 2018
sir,but on lena.jpg no error is coming everything is working fine.Can't we make other images same as lena.jpg.? I tried by changing the size of image but still error is coming.
Geoff Hayes
on 5 Apr 2018
So in your screen shot, look closely at the dimensions for im_n - is 225x225x3. And then with this code
p_im_n= [ zeros(ln,im_sz(2)) ; im_n ; zeros(ln,im_sz(2))];
you are trying to concatenate a 10x225 with a 225x225x3 matrix. Hence the error. I suspect that the Lena.jpg is a 2D image whereas the cameraman is 3D.
To fix this, just do
im_n = im_n(:,:,1);
if it is safe to assume that this image is grayscale (or use the appropriate MATLAB function to convert to grayscale).
Walter Roberson
on 5 Apr 2018
Note: the original cameraman.tif image is 2D -- grayscale.
.jpg images are almost always RGB -- I have only ever seen one true grayscale JPEG that was not artificially created just to demonstrate that it is possible.
The three .jpg images you attached are all RGB images that happen to use only tones of grey.
Komal Gaikwad
on 6 Apr 2018
ok ,sir thanx.One more doubt i have,i have to find variance of an image.I had read the theory of variance still not clear What if variance of first image is greater than the second image?
Walter Roberson
on 6 Apr 2018
"What if variance of first image is greater than the second image"
What about it? That just means it has a higher typical range of values. If the second image is one being computed from the first, it could mean that the second image has been somehow smoothed relative to the first. You appear to be doing some kind of filtering for the purpose of denoising; noise is typically high frequency, so filtered images would tend to have less average change and so would tend to have lower variance.
Komal Gaikwad
on 7 Apr 2018
ok sir,that mean my median filter is giving me the variance of 0.419 and my Wiener filter is giving 0.415.this mean wiener has better variance than median,correct?
Walter Roberson
on 7 Apr 2018
I cannot say that it is "better".
Suppose you take a noisy image, and replace it all by the mean of the image. Then the variation between values would be 0 because they are all identical, so the variance would be 0. All of the information would have been filtered out of it. Is that "better" ?
I have a favorite example of Cosmic Microwave Background Radiation (CMBR): people used to think that it was noise in the astronomy images and worked hard to try to "fix" their systems to be lower noise. But eventually someone realized that there was a real cause for CMBR and that there was a bunch of information in it, and now there is a lot of active study of CMBR -- studies in which they take care to block out known stars as "noise" for this purpose.
"noise" can have information too, and you do not always know where the signal ends and the "real" noise begins.
Walter Roberson
on 8 Apr 2018
Theoretically you can say nothing without more information.
If all you want is to lower the variance then divide the signal by 2 relative to its mean. Lower variance does not mean better signal: it can mean signal of smaller amplitude or it can mean signal that has had information removed. It is even possible to lower variance while increasing noise.
Suppose you were to take a sine wave of a number of cycles, no noise beyond problems with quantization of signals to finite representation. Now randomize the order of the samples. Clearly the result would be noise, and yet it would have the exact same variance. Variance alone cannot tell you how noisy a signal is.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)