# Matlab Image Processing.

• MATLAB
I have to take an image with a narrow intensity histogram and widen its intensity range using a simple transfer function that scales the dominant histogram intensity range [I_min, I_max] to the range [0, 255].

They tell me to tuse a linear function that maps I_min to 0 and I_max to 255 and all intensites I within that range to 255*(I-I_min)/(I_max - I_min).

The problem I am having is how to make it so that the function reads every individual pixel of the image and transforms it to a new pixel value. I am stuck at this part.

Here is my code so far:

function [ output_args ] = imagehisto(image)
%Function that maps pixel values using a transfer function from 0 to 255 if
%it is out of ranage.
% Input of an image, reading each pixel and transferring it to a new
% pixel value.

colormap(gray);
pic2 = rgb2gray(pic);

I_max = double(max(pic2( );
I_min = double(min(pic2( );

x = (0:1:255)
x = pic2
y(I_min+1 : I_max+1) = (255*(x(I_min+1 : I_max+1) - I_min)/(I_max - I_min))
y(1 :I_min) = 0
y(I_max+2 : 256) = 255

imagesc(pic3);

%plot(x,y);
%out_image = transfer_function(pic2);

end

Related MATLAB, Maple, Mathematica, LaTeX News on Phys.org
First I will admitt it has been a while since I have done image analysis with Matlab but what I think you are asking for is something like this. I'm not familiar with the double command so I'll just assume it is used correctly. Oh and don't use image as an imput and image is a command in matlab.

function [ output_args ] = imagehisto(pic)
I_max = double(max(pic( );
I_min = double(min(pic( );
[M,N]=size(pic);
for a=1:M
for b=1:N
pic_new(a,b)=255*(pic(a,b)-I_min)/(I_max-I_min);
end
end
imagesc(pic_new)

I used my own dummy data and I got it so change to the range of 0 to 255, so this should work for you.