필터 지우기
필터 지우기

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by