Help me understand the matlab bwlabel
古いコメントを表示
can anybody explain me what is happening in the code below
[L,Ne]=bwlabel(Bw);
img_wk_bw_L=L==100;
img_wk_bw_L_total=img_wk_bw_L*0;
4 件のコメント
atiqa zahid
2019 年 12 月 5 日
i want to split objects in an image in 4 images.i want help in my assignment. 

Adam Danz
2019 年 12 月 5 日
You might get more attention by starting a new question. But you'll definitely need to share at least a little bit of code to show what you've tried so far. It looks like you've been looking in the right places since you found this question.
atiqa zahid
2019 年 12 月 9 日
% clc; % Clear the command window.
% close all; % Close all figures (except those of imtool.)
% Read the image from disk.
im1 = imread('img11_Inp.jpg');
% Test code if you want to try it with a gray scale image.
% Uncomment line below if you want to see how it works with a gray scale image.
% rgbImage = rgb2gray(rgbImage);
% Display image full screen.
%imshow(im1);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
drawnow;
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows columns numberOfColorBands] = size(im1)
%==========================================================================
% The first way to divide an image up into blocks is by using mat2cell().
blockSizeR = 128; % Rows in block.
blockSizeC = 128; % Columns in block.
% Figure out the size of each block in rows.
% Most will be blockSizeR but there may be a remainder amount of less than that.
wholeBlockRows = floor(rows / blockSizeR);
blockVectorR = [blockSizeR * ones(1, wholeBlockRows), rem(rows, blockSizeR)];
% Figure out the size of each block in columns.
wholeBlockCols = floor(columns / blockSizeC);
blockVectorC = [blockSizeC * ones(1, wholeBlockCols), rem(columns, blockSizeC)];
% Create the cell array, ca.
% Each cell (except for the remainder cells at the end of the image)
% in the array contains a blockSizeR by blockSizeC by 3 color array.
% This line is where the image is actually divided up into blocks.
if numberOfColorBands > 1
% It's a color image.
ca = mat2cell(im1, blockVectorR, blockVectorC, numberOfColorBands);
else
ca = mat2cell(im1, blockVectorR, blockVectorC);
end
% Now display all the blocks.
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);
% Specify the location for display of the image.
subplot(numPlotsR, numPlotsC, plotIndex);
% Extract the numerical array out of the cell
% just for tutorial purposes.
rgbBlock = ca{r,c};
imshow(rgbBlock); % Could call imshow(ca{r,c}) if you wanted to.
[rowsB columnsB numberOfColorBandsB] = size(rgbBlock);
% Make the caption the block number.
caption = sprintf('Block #%d of %d\n%d rows by %d columns', ...
plotIndex, numPlotsR*numPlotsC, rowsB, columnsB);
title(caption);
drawnow;
% Increment the subplot to the next location.
plotIndex = plotIndex + 1;
end
end
% Display the original image in the upper left.
% subplot(4, 6, 1);
% imshow(im1);
% title('Original Image');
% Inform user of next stage where we process a gray scale image.
%promptMessage = sprintf('Now I will do the same for a gray scale image.');
%titleBarCaption = 'Continue?';
%button = questdlg(promptMessage, titleBarCaption, 'OK', 'Cancel', 'OK');
%if strcmpi(button, 'Cancel')
% return;
%end
atiqa zahid
2019 年 12 月 9 日
i put this code ...but this code creates some extra image divisions of original image.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Computer Vision with Simulink についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!