how to divide an image to 4 equal parts and again divide those 4 images into another 4 parts and convert it to a matrix?
1 view (last 30 days)
Show older comments
Hi,
I am doing a project where I want to divide an image first into 4 parts and based on the threshold criteria each part of the main image has to be again divided into another 4 parts and it should carry on till the dim is 1xn or nx1? (As my image is 24x124 it should be divided till 1xn)
I could first divide the image into 4 parts and store as a matrix, but further i am unable to divide each image into another four parts?
Here is my code:
load LTP54
ROI = ZI(37:60,949:1072);
[rows, columns] = size(ROI);
n = 2;
r = rows/n;
c = columns/n;
k = r/n;
l = c/n;
output(:,:,n^2) = zeros(r,c);
op(:,:,n^2) = zeros(k,l);
cnt = 1;
for i=1:n
for j=1:n,
output(:,:,cnt) = ROI((j-1)*r+1:j*r, (i-1)*c+1:i*c);
% I = output(:,:,cnt);
% op(:,:,cnt) = I(((j-1)*k+1:k*r), ((i-1)*l+1:i*l));
cnt = cnt + 1;
end
end
cnt1 = 1;
for i = 1:n
for j = 1:n
I = output(:,:,1);
op(:,:,cnt1) = I(((j-1)*k+1:j*k), ((i-1)*l+1:i*l));
cnt1 = cnt1+1;
end
end
In the second for loop i am able to take only 1 part as my input and divide it into 4 parts, but not all 4 parts of the image.
Could any one help me with this?
0 Comments
Accepted Answer
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!