How to delete odd columns and odd rows from a image
6 views (last 30 days)
Show older comments
Hi, I have to delete odd columns and odd rows from a image. When I import an image it's actually a matrix, so I only have to delete odd columns and odd rows from a matrix. How can i do it?
1 Comment
Dyuman Joshi
on 16 Mar 2023
Edited: Dyuman Joshi
on 16 Mar 2023
im = (randi(256,20,20,3)-1)/255;
imshow(im)
%removing odd rows
im(1:2:end,:,:)=[];
%removing odd columns
im(:,1:2:end,:)=[];
imshow(im)
Answers (1)
Mathieu NOE
on 16 Mar 2023
helllo
try this (A is a array we keep only the even rows and columns)
% create dummy A array
a = (1:10);
for ci = 1:10
A(ci,:) = a*ci;
end
A
%remove odd cols and rows (equivalent to keep even r & c)
[m,n] = size(A);
B = A(2:2:m,2:2:n)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!