- #1
foobag
- 75
- 0
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.
Please help since it is my first time using matlab.
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.
pic = imread(image);
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
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.
Please help since it is my first time using matlab.
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.
pic = imread(image);
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