why following error is appearing when i use other image
1 次查看(过去 30 天)
显示 更早的评论
Error using vertcat Dimensions of matrices being concatenated are not consistent.
15 个评论
Geoff Hayes
2018-4-3
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
2018-4-4
编辑:Walter Roberson
2018-4-5
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
2018-4-4
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
2018-4-5
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
2018-4-5
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
2018-4-5
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
2018-4-6
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
2018-4-6
"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
2018-4-7
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
2018-4-7
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
2018-4-8
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.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)