Is ther any mistake ,as result is not being displayed ,please help out
3 views (last 30 days)
Show older comments
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/150252/image.jpeg)
- MY PROJECT IS ON COLOR IMAGE SEGMENTATION ON MEAN SHIFT AND NORMALIZED CUTS
IN WHICH I HAVE TO DO MEAN SHIFT SEGMENTATION AND THEN TAKE IT AS INPUT FOR NORMALIZED CUTS
1)Initially have done meanshift segmentation on the original Image SUCCESSFUL IN THIS STAGE
2)then taken *Meanshift segmentation result as input for Normalized cut segmentation *
But not getting the output result for Normalized cut segmentation.*
Please Help me out If there is some mistakes made by me in any of the two codes above
*Here is the Demo Code for this project*
%%meanshift parameter
bw = 0.2; % Mean Shift Bandwidth
%%input
I = imread(fullImageFileName); % Original
%%ncut parameters
Ims=Ms2(I,bw);
%if ~exist('write', 'var'), write = false; end;
SI = 5; % Color similarity
SX = 6; % Spatial similarity
r = 1.5; % Spatial threshold (less than r pixels apart)
sNcut = 0.21; % The smallest Ncut value (threshold) to keep partitioning
sArea = 80; % The smallest size of area (threshold) to be accepted as a segment
SegI = NcutImageSegment(Ims, SI, SX, r, sNcut, sArea);
% show
for i=1:length(SegI)
%if ~write
figure; subplot(223),imshow(SegI{i}),title('Normalized and mean shift segmented image');
%else
%imwrite(SegI{i}, sprintf('C:\Users\Poonam\Desktop\MATLAB\R2008a\bin\segmentatioresult\%d.jpg%', i));
- * This is the code part of Normalized cut * *
function SegI = NcutImageSegment(I, SI, SX, r, sNcut, sArea)
% NcutImageSegment - Normalized Cuts and Image Segmentation [1]
%
% Synopsis
% [SegI] = NcutImageSegment(I, SI, SX, r, sNcut, sArea)
%
% Description
% Normalized Cuts and Image Segmentation [1]
%
% Inputs ([]s are optional)
% (matrix) I nRow x nCol x c matrix representing image.
% c is 3 for color image, 1 for grayscale image.
% Let me define N = nRow x nCol.
% (scalar) SI Coefficient used to compute similarity (weight) matrix
% Read [1] for meanings.
% (scalar) SX Coefficient used to compute similarity (weight) matrix
% Read [1] for meanings.
% (scalar) r Coefficient used to compute similarity (weight) matrix
% Definition of neighborhood.
% (scalar) sNcut The smallest Ncut value (threshold) to keep partitioning.
% (scalar) sArea The smallest size of area (threshold) to be accepted
% as a segment.
%
% Outputs ([]s are optional)
% (cell) SegI cell array of segmented images of nRow x nCol x c.
%
% Requirements
% NcutComputeW, NcutPartition, NcutValue
%
[nRow, nCol, c] = size(I);
N = nRow * nCol;
V = reshape(I, N, c); % connect up-to-down way. Vertices of Graph
% Step 1. Compute weight matrix W, and D
W = NcutComputeW(I, SI, SX, r);
% Step 5. recursively repartition
Seg = (1:N)'; % the first segment has whole nodes. [1 2 3 ... N]'
[Seg Id Ncut] = NcutPartition(Seg, W, sNcut, sArea, 'ROOT');
% Convert node ids into images
for i=1:length(Seg)
subV = zeros(N, c); %ones(N, c) * 255;
subV(Seg{i}, :) = V(Seg{i}, :);
SegI{i} = uint8(reshape(subV, nRow, nCol, c)); %#ok<AGROW>
fprintf('%s. Ncut = %f\n', Id{i}, Ncut{i});
end
end
%end
end
subplot(221),imshow(I),title('Original Image');
subplot(222),imshow(Ims),title('Means Shifted Image');
%end
I have taken Ims=Ms(I,bw);// (means shift segmentation which give result in subplot(221))
now for normalized cut
SegI = NcutImageSegment(Ims, SI, SX, r, sNcut, sArea);// * here Ims output result of mean shift segmentation is taken as input for normalized cut segmentation,but getting black color output in the subplot(223) Please help me if there is any mistake i have done *
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!