Error in printing number

1 次查看(过去 30 天)
kash
kash 2012-12-12
I have a code below in which i have error in printing value at the third column
for m3 = 1:(length(dirlist))
I = imread([pathname, dirlist(m3).name]);
A=rgb2gray(I);
A=imresize(A,[256 256]);
J2 = imnoise(A,'salt & pepper',0.2);
Q1=cao(J2);
Q1=imresize(Q1,[256 256]);
Er3= mean2((single(A) - single(Q1)).^2);
error(m3)= mean2((single(A) - single(Q)).^2);
PS(m2) = 20 * log10 (255 / sqrt(Er3));
figure(4),subplot(4,3,m111),imshow(A),title('Original Image')
subplot(4,3,m121),imshow(J2),title('Noise Image')
subplot(4,3,m131),imshow(Q1)
sprintf('Er3 #%d', m131);
m111=m111+3;m121=m121+3;m131=m131+3;
end
I want to print value in Er3 in third column,its not printing ,please help
  1 个评论
Jan
Jan 2012-12-12
编辑:Jan 2012-12-12
@kash: You are the most frequently asking users of this forum. Please, help us to improve the quality of this forum by improving the quality of the questions. Omit all unnecessary lines of code and concentrate on the essential parts. Use code formatting for the code only, not for the complete message. Please read your own question after typing it and check, if a reader has the chance to recognize what you want to explain. Accept answers, which solve your problem. On one hand this is friendly, on the other hand it shows, that readers can care about other threads instead.

请先登录,再进行评论。

回答(1 个)

Jan
Jan 2012-12-12
编辑:Jan 2012-12-12
The code contain a bunch of lines, which do not concern the problem. Posting only the relevant code is more efficient.
Perhaps you mean this line:
sprintf('Er3 #%d', m131);
This creates a string, but does not store it anywhere. Therefore is is useless. Do you mean fprintf to write to the command line? But what does "in third column" mean? Do you want this string to appear as title for the subplot in the 3rd column? Then simply add a title() command and use the sprintf command as argument.
  6 个评论
kash
kash 2012-12-14
they are just variables used for subplotting
Walter Roberson
Walter Roberson 2012-12-14
Replace
sprintf('Er3 #%d', m131);
with
title(sprintf('Er3 #%d', m131));

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Geometric Transformation and Image Registration 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by