필터 지우기
필터 지우기

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 CenterFile Exchange에서 Display Image에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by