Info

この質問は閉じられています。 編集または回答するには再度開いてください。

HOW TO READ THE VALUES IN PARTICULAR BLOCK WHEN THE IMAGE IS CONVERTED INTO CELLS BY USING MAT2CELL

1 回表示 (過去 30 日間)
sonam s
sonam s 2014 年 4 月 11 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
clear all;
im=imread(uigetfile('*.*'));
im=imresize(im,[200 200]);
im=mat2cell(im,[50 50 50 50],[25 25 25 25 25 25 25 25],3);
.i have taken the rgb image.now i have to read the first block i.e.,50 rows, 25 columns.how to seperately read the first block for adding another image to the first block of same size

回答 (1 件)

Image Analyst
Image Analyst 2014 年 4 月 11 日
Just use a nested for loop
[rows, columns] = size(im);
for col = 1 : columns
for row = 1 : rows
thisBlock = im{row, col];
% Now do whatever you want with this 2D array of numbers.
% For example
thisBlock = (double(thisBlock) + double(referenceBlock) / 2; % or whatever...
end
end
  2 件のコメント
sonam s
sonam s 2014 年 4 月 11 日
編集済み: sonam s 2014 年 4 月 11 日
clear all;
im=imread(uigetfile('*.*'));
im=imresize(im,[200 200]);
[x y z]=size(im);
%generate the carrier image
k=1;
for i=1:200
for j=1:200
carry(i,j)=b(k);
k=k+1;
if(k>length(b))
k=1;
end;
end;
end;
figure;
imshow(uint8(carry));
carry=imresize(carry,[50 25]);
title('carrier image')
im=mat2cell(im,[50 50 50 50],[25 25 25 25 25 25 25 25],3);
for col = 1 : 25
for row = 1 : 50
thisBlock = im(row, col);
im=double(im(row,col))+double(carry);
end;
end;
i have written the above code.the carrier image is 2-d text image.this carrier i want to add to the blocks seperately.i have tried the code given by you but it is encountered with an error.please help
Image Analyst
Image Analyst 2014 年 4 月 11 日
Once you view that, you'll probably notice that you are overwriting your whole cell array with the contents of just one block of it added to the carry image. So now you've destroyed im. It's no longer a cell array!

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by