hi guys,
so in my university project, i need to plot a histogram in 12-bit portrayal (the x-axis is from 0 - 4096 gray values) from an 16-bit image.. with software ImageJ i could do that with no problem at all, i just need to divide the image with 16 (16bit / 16 = 12bit, 65536/16 = 4096) and then i just call the histogram... i wish i could show you how it looks like, but there's no option here to attach something..
in matlab i've written this code:
f = imread('D:\.....\20091007080643421.tif');
imhist(f), ylim([0,21000]); %figure 1
g = imdivide(f,16);
figure, imhist(g), ylim([0,21000]); %figure 2
figure, imhist(g), ylim([0,21000]), xlim([0,4096]); %figure 3 is the same as figure 2, with different scale
but it looks completely different from with what i've done in ImageJ... but i really need to make this in matlab for this project..
can somebody please help me..?
cheers,
Dalle
|
|
0
|
|
|
|
Reply
|
Dalle
|
6/5/2010 1:26:04 PM |
|
Dalle:
fromt he help: "imhist(I, n) displays a histogram where n specifies
the number of bins used in the histogram. "
Run this demo and you'll understand:
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
% 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.
% Let's get its histogram.
[pixelCount grayLevels] = imhist(grayImage);
subplot(2, 2, 2);
bar(pixelCount);
title('Histogram of original image');
xlim([0 grayLevels(end)]); % Scale x axis manually.
% Convert to a 16 bit image
grayImage16 = 256 * uint16(grayImage);
% Let's get its 16 bit histogram.
numberOfBins16 = double(intmax('uint16'));
[pixelCount16 grayLevels16] = imhist(grayImage16, numberOfBins16);
subplot(2, 2, 3);
bar(grayLevels16, pixelCount16);
title('Histogram of 16 bit image');
xlim([0 grayLevels16(end)]); % Scale x axis manually.
% Convert 16 bit image to a 12 bit image.
grayImage12 = uint16(grayImage16 / 16);
numberOfBins12 = round(numberOfBins16 / 16);
% Let's get its 12 bit histogram.
[pixelCount12 grayLevels12] = imhist(grayImage12, numberOfBins12);
subplot(2, 2, 4);
bar(grayLevels12, pixelCount12);
title('Histogram of 12 bit image');
xlim([0 grayLevels12(end)/16]); % Scale x axis manually.
|
|
0
|
|
|
|
Reply
|
ImageAnalyst
|
6/5/2010 2:50:45 PM
|
|
ImageAnalyst <imageanalyst@mailinator.com> wrote in message <b791d49b-0a72-4d0d-a3b8-403da498fbbc@d37g2000yqm.googlegroups.com>...
> Dalle:
> fromt he help: "imhist(I, n) displays a histogram where n specifies
> the number of bins used in the histogram. "
>
> Run this demo and you'll understand:
>
> 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
>
> % 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.
>
> % Let's get its histogram.
> [pixelCount grayLevels] = imhist(grayImage);
> subplot(2, 2, 2);
> bar(pixelCount);
> title('Histogram of original image');
> xlim([0 grayLevels(end)]); % Scale x axis manually.
>
> % Convert to a 16 bit image
> grayImage16 = 256 * uint16(grayImage);
>
> % Let's get its 16 bit histogram.
> numberOfBins16 = double(intmax('uint16'));
> [pixelCount16 grayLevels16] = imhist(grayImage16, numberOfBins16);
> subplot(2, 2, 3);
> bar(grayLevels16, pixelCount16);
> title('Histogram of 16 bit image');
> xlim([0 grayLevels16(end)]); % Scale x axis manually.
>
> % Convert 16 bit image to a 12 bit image.
> grayImage12 = uint16(grayImage16 / 16);
> numberOfBins12 = round(numberOfBins16 / 16);
>
> % Let's get its 12 bit histogram.
> [pixelCount12 grayLevels12] = imhist(grayImage12, numberOfBins12);
> subplot(2, 2, 4);
> bar(grayLevels12, pixelCount12);
> title('Histogram of 12 bit image');
> xlim([0 grayLevels12(end)/16]); % Scale x axis manually.
>
>
my god... you're really a genius aren't you :D
thx so much ImageAnalyst, that's really make my life easier now, hehehe..
again thx a bunch!
|
|
1
|
|
|
|
Reply
|
Dalle
|
6/5/2010 3:10:05 PM
|
|
|
2 Replies
501 Views
(page loaded in 0.022 seconds)
Similiar Articles: how to plot histogram in 12-bit from an 16-bit image? - comp.soft ...hi guys, so in my university project, i need to plot a histogram in 12-bit portrayal (the x-axis is from 0 - 4096 gray values) from an 16-bit image... 16 bits signed image display - comp.soft-sys.matlabhow to plot histogram in 12-bit from an 16-bit image? - comp.soft ... Output to 16 bit greyscale .raw ? - comp.graphics.apps.gimp ... 16-bit Image Display - Eye Physics ... how to plot histograms on - comp.soft-sys.matlabhow to plot histogram in 12-bit from an 16-bit image? - comp.soft ... hi guys, so in my university project, i need to plot a histogram in 12-bit portrayal (the x-axis is ... Output to 16 bit greyscale .raw ? - comp.graphics.apps.gimp ...how to plot histogram in 12-bit from an 16-bit image? - comp.soft ... Output to 16 bit greyscale .raw ? - comp.graphics.apps.gimp ... 16-bit Image Display - Eye Physics ... Normalizing grayscale image - comp.soft-sys.matlabhow to plot histogram in 12-bit from an 16-bit image? - comp.soft ... Normalizing grayscale image - comp.soft-sys.matlab Reply: sjye: 12/16/2010 3:20:23 AM ... 16 bit ... Extracting bit planes from Images - comp.soft-sys.matlab ...... between imagesc, image, and imshow and how do you ... rgb ... RGB Histogram - comp ... extract the various bit planes ... for ... has 8 x 12 bit analog inputs, 2 x 16 bit ... imhist - comp.soft-sys.matlabOn May 12, 2:58=A0pm, "Dave Robinson ... your matrix will be normalized to 8-bit ... matlab... imshow(I); h = imhist(I);%image histogram ch = cumsum(h);%cumulative histogram plot ... high density scatterplot - comp.soft-sys.matlab... can find a contribution for n-dimensional histograms. ... plot(x,y,'o') % This one is a wee bit better plot(x,y,'.') ... 8/12/2010 8:16:07 PM How to clear an object plot - comp.lang.idl-pvwaveWhen the user moves his mouse over this image, the z ... you, waiting for the New Graphics to mature a bit. ... how to plot histograms on - comp.soft-sys.matlab I have two ... Reducing the Gray Levels in a Greyscale Image - comp.soft-sys ...ImageAnalyst: 12/8/2010 4:07:38 AM ... 16 bit greyscale to 4 bit image translation - comp.soft-sys.matlab ... ... grayscale image - comp.soft-sys.matlab Histogram ... how to plot histogram in 12-bit from an 16-bit image? - comp.soft ...hi guys, so in my university project, i need to plot a histogram in 12-bit portrayal (the x-axis is from 0 - 4096 gray values) from an 16-bit image... How to rescale an image from 16 bit to 12 bit? - Newsreader ...that this is how it is by taking a histogram. Do you have gaps ... zero and the packs the camera's 12 bits into the upper 12 > bits of the 16 bit word. This is so the image ... 7/23/2012 12:57:21 AM
|