# histogram of 3D intensity image and normalize the intensity by linearly fitting the histogram to the ICBM-152

49 views (last 30 days)
crus on 2 Jun 2013
Answered: Shaode Yu on 7 May 2019
Hi，everyone
I have a 3D (256*124*256) intensity medical image(*.hdr/*.img)(I will call it image A later),and the standarded 3D intensity image named ICBM-152(197*233*189)(image B). first,I want to obtain histigram of these two 3D image.imhist doesn't work on 3D image. second,like the function histeq(f,hspec),I want to match the histogram of image A with that of image B. Wish you can help me,it is important for me. THANKS!
Makrim on 14 May 2015
please, keep me informed in case you find a solution.... thank you in advance

Image Analyst on 2 Jun 2013
There is a imhistmatch() function in newer versions of MATLAB:
imhistmatch
Adjust histogram of image to match N-bin histogram ofreference image
Syntax
B = imhistmatch(A,Ref) example
B = imhistmatch(A,Ref,N) example
[B,hgram]= imhistmatch(___) example
Description
example
B = imhistmatch(A,Ref) image A istransformed so that the histogram of the returned image B approximatelymatches the histogram of reference image Ref builtwith 64 (default value) equally spaced histogram bins. The returnedimage B will have no more than 64 discrete levels.
Images A and Ref canbe any of the permissible data types.
If both A and Ref aretruecolor RGB images, then each color channel of A ismatched independently to the corresponding color channel of Ref.
If A is a truecolor RGB imageand Ref is a grayscale image, then each channelof A is matched against the single histogramderived from Ref.
If A is a grayscale image, then Ref mustalso be a grayscale image.
Images A and Ref neednot be equal in size.
If you want a more accurate version, then you'll have to use the histogram shaping application in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/28972-custom-shaped-histogram

Iman Ansari on 2 Jun 2013
A=uint8(randi(256,256,124,256)-1);
H1=imhist(A(:));
% Or
%H2=histc(A(:),0:255);
B=repmat(B(:,1:124),[1 1 256]);
C=imhistmatch(A,B,256);
subplot(131)
imhist(A(:))
subplot(132)
imhist(B(:))
subplot(133)
imhist(C(:))
Iman Ansari on 2 Jun 2013
A=uint8(randi(256,256,124,256)-1);
H1=imhist(A(:));
% Or
%H1=histc(A(:),0:255);
B=repmat(B(1:197,1:233),[1 1 189]);
H2=imhist(B(:));
C=histeq(A(:),H2);
C=reshape(C,size(A));
subplot(131)
imhist(A(:))
subplot(132)
imhist(B(:))
subplot(133)
imhist(C(:))

Makrim on 14 May 2015
How about running trough the cubic image A and B, slice by slice. I mean why don't your first register one image (dimension 2) from A to an image from the atlas B, and then compute the histogram of both with no trouble.

Shaode Yu on 7 May 2019
Please check this function. It performs well on 3D images.