Borrar filtros
Borrar filtros

Error in output image

4 visualizaciones (últimos 30 días)
FIR el 22 de Dic. de 2012
I have a image converted to quanterion form,now i have performed some operation on that code
My code is
A = imread('peppers.png');
qlena = convert(quaternion(lena(:,:,1), ...
lena(:,:,2), ...
lena(:,:,3)), 'double') ./ 256;
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;
S=min(abs(([V1 V2 V3 V4])));
if S>T
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);
my final output is not a peppers image,it chows some blocks with different colours please help

Respuestas (1)

Walter Roberson
Walter Roberson el 22 de Dic. de 2012
Editada: Walter Roberson el 22 de Dic. de 2012
You overwrite qVFM within the loop, not using its value until you exit the loop. Is that really what you want to do ?
  2 comentarios
FIR el 24 de Dic. de 2012
no walter i want to replacE the centre pixel by qvfm if S>T
Image Analyst
Image Analyst el 24 de Dic. de 2012
Editada: Image Analyst el 24 de Dic. de 2012
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!"

Iniciar sesión para comentar.


Community Treasure Hunt

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

Start Hunting!

Translated by