To divide an image into 2 equal halves
이전 댓글 표시
I wrote the code for it . I can divide the left side of an image and while doing for the right side left part of it is black and right part is the second half of the image . The problem where i am facing is , in the 2nd for loop it starts with k=1 n m=110 so for others column values from 1 to 109 as a default its taking zero. How to sort out this problem.
% code
x=imread('img1.jpg');
image=rgb2gray(x);
[q r]=size(image);
s=r/2;
for i=1:q
for j=1:s
n1(i,j)=image(i,j);
end
end
for k=1:q
for m=s:r
n2(k,m)=image(k,m);
end
end
imshow(n1)
figure
imshow(n2)
end
댓글 수: 4
keerthi
2012년 9월 27일
Walter Roberson
2012년 9월 27일
Look in the documentation about array indexing.
Durgesh Naik
2015년 4월 3일
till not working
Image Analyst
2015년 4월 3일
How do you know? Did you ask keerthi? He accepted the answer so I would assume that it is working.
채택된 답변
추가 답변 (2개)
Jay Li
2018년 5월 10일
1 개 추천
function y = halfpic(x)
% Enter an image in matrix form
n = floor(size(x)/2)
m = size(x);
Lpic = x(:,1:n(2),:);
Rpic = x(:,n(2)+1:m(2),:);
imshow(Lpic);
figure
imshow(Rpic);
댓글 수: 1
mariena aloor
2019년 9월 10일
How to divide an image in to 8 regions
JEBA CHRISTILDA
2016년 8월 9일
0 개 추천
yes i too tried this but it is showing error in imshow(n1)
카테고리
도움말 센터 및 File Exchange에서 Image Arithmetic에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!