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
atiqa zahid 2019년 12월 5일
i want to split objects in an image in 4 images.i want help in my assignment.
Adam Danz
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
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
atiqa zahid 2019년 12월 9일
i put this code ...but this code creates some extra image divisions of original image.

댓글을 달려면 로그인하십시오.

 채택된 답변

Image Analyst
Image Analyst 2017년 4월 11일

1 개 추천

It labels the binary image so that each connected blob had an "ID number", called the label. L is an image of pixels with the value being the label that they have been assigned. For example if you have 2 blobs, the not-very-descriptively-named Ne will be 2 and each blob in L will have values of either 1 or 2 for the pixels in that blob.
The next line just creates an image of blob #100. All other blobs are removed.
The next line just creates an image of all zeros, essentially wiping away blob #100 that you just extracted. I don't know why anyone would do that. It's essentially the same as
img_wk_bw_L_total = false(size(L));
an all black/0/false binary image.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Blue에 대해 자세히 알아보기

태그

질문:

2017년 4월 11일

댓글:

2019년 12월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by