フィルターのクリア

What do I use and where do I use it?

1 回表示 (過去 30 日間)
N/A
N/A 2019 年 2 月 7 日
コメント済み: N/A 2019 年 2 月 7 日
rgbImage = imread(fullFileName);
imshow(rgbImage); set(gcf, 'units','normalized','outerposition',[0 0 1 1]); drawnow;
[rows, columns, numberOfColorBands] = size(rgbImage); blockSizeR = 40; %Rows in block.
blockSizeC = 40; %Rows in column.
wholeBlockRows = floor(rows / blockSizeR);
blockVectorR = [blockSizeR * ones(1, wholeBlockRows), rem(rows, blockSizeR)];
wholeBlockCols = floor(columns / blockSizeC);
blockVectorC = [blockSizeC * ones(1, wholeBlockCols), rem(columns, blockSizeC)];
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); fileID = fopen('AB_45.xls','wt'); NewID = 'Book1.xls';
numbers = [];
for r = 1 : numPlotsR
for c = 1 : numPlotsC
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;
img1=rgbBlock;
imshow(img1)
img2=imbinarize(img1,graythresh(img1)); imshow(img2)
img2=~img2; imshow(img2)
B = bwboundaries(img2); imshow(img2)
numbers = [numbers ; (length(B))];
hold on
for k = 1:length(B)
boundary = B{k};
text(10,10,strcat('\color{green}',num2str(length(B))))
fprintf(' \n');
end
end
end
xlswrite(NewID,numbers,1,'A1:AN40');
  3 件のコメント
N/A
N/A 2019 年 2 月 7 日
George - I tried that but the excel file output only used 0 to fill all rows and colums which should not be.
Geoff Hayes
Geoff Hayes 2019 年 2 月 7 日
What is numbers being set to on each iteration of the loop? Please show your updated code.

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

回答 (1 件)

Image Analyst
Image Analyst 2019 年 2 月 7 日
Assign numbers like this:
numbers(plotIndex) = length(B);
You need to define newID.
Also, call xlswrite() just once after your double for loop.
And your look over k just puts up a label for each boundary in the same place at (10,10), which seems unwise.
  1 件のコメント
N/A
N/A 2019 年 2 月 7 日
Can you explain further what you mean by how to assign number;
NewID has already been defined.
xlswrite() is occurring just once.
Can you kindly elaborate on what to do.
Thank you

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

カテゴリ

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

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by