How can you extract odd and even rows and columns from image to seperate image outputs
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Saphsa Codling
el 6 de Dic. de 2019
Comentada: Saphsa Codling
el 23 de Jul. de 2020
Hi there. I might be overthinking this. I often do but I'm trying to take the odd columns and rows and then even rows and columns from an image and then output them to form two seperate images in a subplot, with the original image maintained. I am confused at how I handle the additional dimension and I think this might be causing the output to fail. Any advice would be much appreciated. Code below.
%Load image
function [RowsEven, ColsEven]=oddevenpic(A);
A=imread('brain.jpg');
sizeofarray=size(A);
B=zeros(sizeofarray(1), sizeofarray(2));
C=zeros(sizeofarray(1), sizeofarray(2));
image(B);
image(C);
for r=1:sizeofarray(1);
for c=1:sizeofarray(2);
for RowsEven=mod(A,r)==0;
for ColsEven=mod(A,c)==0;
if (A(r)==RowsEven) | (A(c)==ColsEven);
(B(r)==RowsEven) & (B(c)==ColsEven);
else
(C(r)==(A(r)~=RowsEven)) & (C(c)==(A(c)~=ColsEven));
end
end
end
end
end
% %Display
subplot(3,2,3);
imshow(A);
title('Original Image')
%
subplot(3,2,2);
imshow(B);
title('Even Pixels Only')
%
subplot(3,2,1);
imshow(C)
title('Odd Pixels Only')
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0, 1, 1]);
0 comentarios
Respuesta aceptada
JESUS DAVID ARIZA ROYETH
el 6 de Dic. de 2019
B=A(2:2:size(A,1),2:2:size(A,2),:);%Even Pixels Only
C=A(1:2:size(A,1),1:2:size(A,2),:);%Odd Pixels Only
3 comentarios
NIKHIL SINGH
el 23 de Jul. de 2020
can u share the final code which gave the output after making changes
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!