is there a way so that we extract a particular block from an 8x8 image?

1 回表示 (過去 30 日間)
Raman
Raman 2013 年 3 月 10 日
i've an image of size 8x8 blocks i.e total of 64 blocks.
i want to extract or show only few blocks...
how can i do so?
for row = 1 : blockSizeR : rows
for col = 1 : blockSizeC : columns
row1 = row;
row2 = row1 + blockSizeR - 1;
row2 = min(rows, row2);
% Determine starting and ending columns.
col1 = col;
col2 = col1 + blockSizeC - 1;
col2 = min(columns, col2);
% Extract out the block into a single subimage.
oneBlock = grayImage(row1:row2, col1:col2);
% Specify the location for display of the image.
subplot(6,8, blockNumber);
imshow(oneBlock);
end
end
the above code shows all the 64 blocks..
what should i do, so that only block 10 and block 34 is show rather than all the blocks..
if there is a way tell me how to do it..
  5 件のコメント
Raman
Raman 2013 年 3 月 11 日
編集済み: Raman 2013 年 3 月 11 日
how can can i do so? can u help me sir by writing few lines of code plz..
reply plz
Raman
Raman 2013 年 3 月 12 日
can anyone help me plz....

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2013 年 3 月 12 日
編集済み: Walter Roberson 2013 年 3 月 12 日
blockrows =8; blockcols = 8;
[blockcol, blockcol] = ind2sub( [blockcols, blockrows], BlockNumber]
colstart = (blockcol-1) * blockSizeC + 1;
rowstart = (blockrow - 1) * blockSizeR + 1;
oneBlock = grayImage(rowstart : rowstart + blockSizeR - 1, colstart : colstart + blockSizeC - 1);
  3 件のコメント
Walter Roberson
Walter Roberson 2013 年 3 月 12 日
Sorry, should have been ind2sub() rather than idx2subs()
Do not enclose this in a "for" loop. The above is the complete code to extract by block number. For example to extract block #34, use those lines of code with BlockNumber = 34
Raman
Raman 2013 年 3 月 12 日
thank you so much it works....
:)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by