필터 지우기
필터 지우기

histogram of image

조회 수: 1 (최근 30일)
Tricky
Tricky 2012년 5월 13일
Hi..
what is bimodel histogram and how apply it to the image. For what it is used

답변 (2개)

Image Analyst
Image Analyst 2012년 5월 13일
It is a probability distribution function of the intensity values in the image. If it's bimodal it means that there are predominantly two types of things in the image: bright things and dark things. You don't apply it to the image. You might look at it to decide where to threshold the image into foreground and background.
  댓글 수: 1
Tricky
Tricky 2012년 5월 15일
Thnaks IA and can I get a Demo this ?

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


Image Analyst
Image Analyst 2012년 5월 15일
Here's your demo:
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.
fontSize = 20;
% Change the current folder to the folder of this m-file.
if(~isdeployed)
cd(fileparts(which(mfilename)));
end
% Check that user has the Image Processing Toolbox installed.
hasIPT = license('test', 'image_toolbox');
if ~hasIPT
% User does not have the toolbox installed.
message = sprintf('Sorry, but you do not seem to have the Image Processing Toolbox.\nDo you want to try to continue anyway?');
reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
if strcmpi(reply, 'No')
% User said No, so exit.
return;
end
end
% Read in a standard MATLAB gray scale demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'cameraman.tif';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% File doesn't exist -- didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
grayImage = imread(fullFileName);
% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[rows columns numberOfColorBands] = size(grayImage);
% Display the original gray scale image.
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Give a name to the title bar.
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
% Let's compute and display the histogram.
[pixelCount grayLevels] = imhist(grayImage);
subplot(2, 2, 2);
bar(pixelCount);
title('Histogram of original image', 'FontSize', fontSize);
xlim([0 grayLevels(end)]); % Scale x axis manually.
grid on;
% Specify a threshold
thresholdValue = 50;
% Put a vertical line on the histogram at the threshold.
yl = ylim();
line([thresholdValue thresholdValue], yl, 'Color', 'r', 'LineWidth', 2);
% Threshold the image.
binaryImage = grayImage < thresholdValue;
% Display the binary image.
subplot(2, 2, 3);
imshow(binaryImage, []);
title('Binary Image', 'FontSize', fontSize);
% Get a masked image.
maskedImage = zeros(rows, columns);
maskedImage(binaryImage) = grayImage(binaryImage);
% Display the binary image.
subplot(2, 2, 4);
imshow(maskedImage, []);
title('Masked Image', 'FontSize', fontSize);

카테고리

Help CenterFile Exchange에서 Deep Learning for Image Processing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by