Filter löschen
Filter löschen

What do I use and where do I use it?

1 Ansicht (letzte 30 Tage)
N/A
N/A am 7 Feb. 2019
Kommentiert: N/A am 7 Feb. 2019
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 Kommentare
N/A
N/A am 7 Feb. 2019
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 am 7 Feb. 2019
What is numbers being set to on each iteration of the loop? Please show your updated code.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 7 Feb. 2019
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 Kommentar
N/A
N/A am 7 Feb. 2019
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

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by