i dont know iwhether my code is right for extraction of patch from the right side of an image.
Here is the code:
figure;
[rowsl, columnsl]=size(iml);
blockSizeR=10;
blockSizeC=10;
% [rowsl, columns1]=size(iml);
% for row = 1 : blockSizeR : rowsl
% for col = 1 : blockSizeC : columns1
% patch(:)= iml(:,columnsl:columnsl-blockSizeC);
% imshow(patch);
% end
% end%

2 commentaires

KALYAN ACHARJYA
KALYAN ACHARJYA le 20 Juin 2019
Please share the image, also explain the question clearly.
Pravita Lekshmanan
Pravita Lekshmanan le 20 Juin 2019
Sir i need to crop or extract simultaneous patches continuously from top right till bottom left of an image as shown below:
new.JPG
a blocksize of 10x10 like shown below and i need to plot it on a figure as subplots
crop.JPG
I dont know how to do the same

Connectez-vous pour commenter.

 Réponse acceptée

KALYAN ACHARJYA
KALYAN ACHARJYA le 20 Juin 2019
Modifié(e) : KALYAN ACHARJYA le 20 Juin 2019

0 votes

im=imread('new.jpeg');
k=1;
[rows colm]=size(im);
for i=1:10:rows-10
for j=1:10:colm-10
im_sub=im(i:i+9,j:j+9);
subplot(round(rows/10),round(colm/10),k),imshow(im_sub);
k=k+1;
end
end
Please note: If you do the same without loop, which is recomended. Also look at Block Processing
You can also save the all blocks in structure and call the individual cell struture in later.
im=imread('new.jpeg');
k=1;
im_sub={ };
[rows colm]=size(im);
for i=1:10:rows-10
for j=1:10:colm-10
im_sub{k}=im(i:i+9,j:j+9);
k=k+1;
end
end
Next do the imshow of individual blocks.

5 commentaires

Pravita Lekshmanan
Pravita Lekshmanan le 21 Juin 2019
Thankyou sir somuch it works well for my work.
Really thankful for your answer
KALYAN ACHARJYA
KALYAN ACHARJYA le 21 Juin 2019
Modifié(e) : KALYAN ACHARJYA le 21 Juin 2019
@Pravita Happy to know that
Lets Keep Learning!
Pravita Lekshmanan
Pravita Lekshmanan le 3 Juil 2019
sir if i have need to extract patches from the right side of the image
Columns wise how should i change the above code?
Sir could you please spare me and explain it
KALYAN ACHARJYA
KALYAN ACHARJYA le 3 Juil 2019
j=colm:-10:11
Pravita Lekshmanan
Pravita Lekshmanan le 4 Juil 2019
sir when i run my code for columnsI=173, it says
for i = 1 : 50 : rowsI-50
for j = columnsI : -50 : 51
im_subL=I(i:i+49,j:j+49);
im_subR=imr(i:i+49,j:j+49);
Index in position 2 exceeds array bounds (must not exceed 173).
Error in new (line 115)
im_subL=I(i:i+49,j:j+49);
why is it so could you please tell me

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by