フィルターのクリア

How do I store patches in order?

2 ビュー (過去 30 日間)
Md Farhad Mokter
Md Farhad Mokter 2019 年 6 月 11 日
コメント済み: Md Farhad Mokter 2019 年 6 月 13 日
I am the given code for creating 28*28 patches from a 224*224 image.
fullFileName='sample.bmp';
rgbImage = imread(fullFileName);
imshow(rgbImage);
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
drawnow;
[rows columns numberOfColorBands] = size(rgbImage)
blockSizeR = 28; % Rows in block.
blockSizeC = 28; % Columns in block.
wholeBlockRows = floor(rows / blockSizeR);
blockVectorR = [blockSizeR * ones(1, wholeBlockRows)];
wholeBlockCols = floor(columns / blockSizeC);
blockVectorC = [blockSizeC * ones(1, wholeBlockCols)];
if numberOfColorBands > 1
ca = mat2cell(rgbImage, blockVectorR, blockVectorC, numberOfColorBands);
else
ca = mat2cell(rgbImage, blockVectorR, blockVectorC);
end
plotIndex = 1;
numPlotsR = size(ca, 1);
numPlotsC = size(ca, 2);
for r = 1 : numPlotsR
for c = 1 : numPlotsC
fprintf('plotindex = %d, c=%d, r=%d\n', plotIndex, c, r);
subplot(numPlotsR, numPlotsC, plotIndex);
rgbBlock = ca{r,c};
imshow(rgbBlock);
[rowsB columnsB numberOfColorBandsB] = size(rgbBlock);
caption = sprintf('Block #%d of %d\n%d rows by %d columns', ...
plotIndex, numPlotsR*numPlotsC, rowsB, columnsB);
title(caption);
drawnow;
plotIndex = plotIndex + 1;
end
end
Now I want to store those patches in the order they are created, so that, for first row there are 8 patches and second row starts with 9th patch. I also want to store those patches with same name as original image with an extension at the end. For example if the image name is sample.bmp, the patches should be named like sample_01, sample_02...like this.
  3 件のコメント
Image Analyst
Image Analyst 2019 年 6 月 12 日
Maybe he wants to save them as new images to disk, so those are filenames, rather than creating variables with that name. Maybe the poster can clarify what "store" means to him.
Md Farhad Mokter
Md Farhad Mokter 2019 年 6 月 13 日
I want to save each of the patches as an image file in my disk. For each input image, I want to get 64 patches with same name as original file.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeDisplay Image についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by