From: leila on 2 May 2010 08:10 haw can i remove backgroud using global threshold
From: ImageAnalyst on 2 May 2010 12:48 On May 2, 12:10 pm, leila <leeeila12...(a)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 = 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 = 150; backgroundImage = grayImage > thresholdValue; % or you can use > subplot(2, 2, 2); imshow(backgroundImage, []); title('Binary Image of Background'); grayImage(backgroundImage) = 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.
|
Pages: 1 Prev: Convert .avi to .bin (binary) file Next: ccs 3.1 and matlab |