Error in output image

조회 수: 3 (최근 30일)
FIR
FIR 2012년 12월 22일
I have a image converted to quanterion form,now i have performed some operation on that code
My code is
A = imread('peppers.png');
lena=impulsenoise(A,0.3,1);
qlena = convert(quaternion(lena(:,:,1), ...
lena(:,:,2), ...
lena(:,:,3)), 'double') ./ 256;
A=qlena;
T=35;
for i=2:6
for j=2:6
q= convert(A(i-1:i+1,j-1:j+1),'single');
[minsum, minidx] = min( sum(abs(repmat(q(:),1,9)-repmat(q(:).',9,1))));
qVFM =minsum;
V1=(abs(q(4)+q(6)))/2;
V2=(abs(q(3)+q(7)))/2;
V3=(abs(q(2)+q(4)))/2;
V4=(abs(q(1)+q(9)))/2;
S=min(abs(([V1 V2 V3 V4])));
if S>T
qVFM=q(2,2);
else
qVFM=q;
end
end
end
temp = convert(qVFM.* 256, 'uint8');
edge = zeros(size(temp, 1), size(temp, 2), size(temp, 3), 'uint8');
edge(:,:,1) = x(temp);
edge(:,:,2) = y(temp);
edge(:,:,3) = z(temp);
image(edge)
my final output is not a peppers image,it chows some blocks with different colours please help

답변 (1개)

Walter Roberson
Walter Roberson 2012년 12월 22일
편집: Walter Roberson 2012년 12월 22일
You overwrite qVFM within the loop, not using its value until you exit the loop. Is that really what you want to do ?
  댓글 수: 2
FIR
FIR 2012년 12월 24일
no walter i want to replacE the centre pixel by qvfm if S>T
Image Analyst
Image Analyst 2012년 12월 24일
편집: Image Analyst 2012년 12월 24일
And what are i and j looping over? The window? Where are the loops over rows and columns of the entire image? A sliding window type of filter has 4 nested for loops, not two. Which array is your output image? Why do i and j only go from 2 to 6? This is just a 5 by 5 patch in the upper left corner of your image. That's just a window. Is the window supposed to scan around the entire image? If so, again, where are the loops over rows and columns?
DON'T USE EDGE as the name of your variable since that is a built-in function name.
Why do you set qVFM equal to one single element of q if S>T, but if S<=T you set qVFM equal to the whole multi-element q matrix? What is qVFM supposed to be? Is it a single number or an entire 3x3 array???
Why do you initialize qVFM to minsum when you overwrite it later and never ever use it as that value. It can't have that value - well it can but it's never used because it's immediately overwritten.
Since you display edge (which is your image now that you've destroyed the "edge" function) it appears to be your output image, but you never say edge(row, column) = qVFM!!! In fact you set edge equal to x, y, and z but you never initialized those arrays, at least that you showed us. How does this thing even run? It should throw an exception when it tries to assign x to edge.
The whole code is just a mess and I suggest you undertake a thoughtful re-write. Perhaps adding some comments will guide you to making the proper lines of code.
Finally, "chows" means "eats" especially in a hurry or a great volume of food, as in "He really chows down those peppers like there's no tomorrow!"

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by