haw can i remove backgroud using global threshold
|
|
0
|
|
|
|
Reply
|
leeeila12345 (19)
|
5/2/2010 12:10:45 PM |
|
On May 2, 12:10=A0pm, leila <leeeila12...@live.fr> wrote:
> haw can i remove backgroud using global threshold
---------------------------------------------------------
If it's even possible, you'd do something like this:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
% Change the current folder to the folder of this m-file.
% (The line of code below is from Brett Shoelson of The Mathworks.)
if(~isdeployed)
cd(fileparts(which(mfilename)));
end
% Read in standard MATLAB grayscale demo image.
grayImage =3D imread('cameraman.tif');
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image');
set(gcf, 'Position', get(0,'Screensize')); % Enlarge figure to full
screen.
thresholdValue =3D 150;
backgroundImage =3D grayImage > thresholdValue; % or you can use >
subplot(2, 2, 2);
imshow(backgroundImage, []);
title('Binary Image of Background');
grayImage(backgroundImage) =3D 0; % or whatever value you want.
subplot(2, 2, 3);
imshow(grayImage, []);
title('Original with black background');
%-------------------- end of code --------------------------------
See this demo for another example:
http://www.mathworks.com/matlabcentral/fileexchange/25157
Sometimes the background cannot be identified by a global threshold.
|
|
0
|
|
|
|
Reply
|
ImageAnalyst
|
5/2/2010 4:48:12 PM
|
|