here is my code i cannot understand the error in it can any one will help me to locate the error

조회 수: 1 (최근 30일)
close all;
clear;
%Read Background Image
Backg=imread('blk.jpg');
%Read Current Frame
CurrentFrame=imread('2.jpg');
%Display Background and Foreground
subplot(2,2,1);imshow(Backg);title('BackGround');
subplot(2,2,2);imshow(CurrentFrame);title('Current Frame');
%Convert RGB 2 HSV Color conversion
[Background_hsv]=round(rgb2hsv(Backg));
[CurrentFrame_hsv]=round(rgb2hsv(CurrentFrame));
Out = bitxor(Background_hsv,CurrentFrame_hsv);
%Convert RGB 2 GRAY
Out=rgb2gray(Out);
%Read Rows and Columns of the Image
[rows,columns]=size(Out);
BinaryImage = zeros(:, 'int8');
%Convert to Binary Image
for i=1:rows
for j=1:columns
if Out(i,j) >0
BinaryImage(i,j)=1;
else
BinaryImage(i,j)=0;
end
end
end
%Apply Median filter to remove Noise
FilteredImage=medfilt2(BinaryImage,[5 5]);
%Boundary Label the Filtered Image
[L ,num]=bwlabel(FilteredImage);
STATS=regionprops(L,'all');
cc=[];
removed=0;
%Remove the noisy regions
for i=1:num
dd=STATS(i).Area;
if (dd < 500)
L(L==i)=0;
removed = removed + 1;
num=num-1;
else
end
end
[L2 ,num2]=bwlabel(L);
% Trace region boundaries in a binary image.
[B,L,N,A] = bwboundaries(L2);
%Display results
subplot(2,2,3), imshow(L2);title('BackGround Detected');
subplot(2,2,4), imshow(L2);title('Blob Detected');
hold on;
for k=1:length(B),
if(~sum(A(k,:)))
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'r','LineWidth',2);
for l=find(A(:,k)),
boundary = B{l};
plot(boundary(:,2), boundary(:,1), 'g','LineWidth',2);
end
end
end
  댓글 수: 2
dpb
dpb 2015년 8월 28일
Well, you could at least give a hint...since we don't have your input file, can't run it so not much can do simply by looking at the code without foreknowledge of what are supposed to be looking for...
bushra mughal
bushra mughal 2015년 8월 28일
I want to use this code for background removal and detection of breast masses

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

채택된 답변

Walter Roberson
Walter Roberson 2015년 8월 28일
BinaryImage = zeros(:, 'int8');
is not valid syntax. You want
BinaryImage = zeros(rows, columns, 'int8');
By the way: what is the output of
logical(Out)
?
  댓글 수: 2
bushra mughal
bushra mughal 2015년 8월 28일
Undefined function 'bakground' for input arguments of type 'char'.
Walter Roberson
Walter Roberson 2015년 8월 28일
You have no reference to anything like that in the code you posted. But if I were you I would change your code to refer to 'background' instead of 'bakground'

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Camera Calibration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by