help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Separating image band alters histogram


From: Terry Duell
Subject: Separating image band alters histogram
Date: Sat, 29 Sep 2012 12:48:59 +1000
User-agent: Opera Mail/11.64 (Linux)

Hello All,
For various reasons, I have been extracting the bands from RGB images, and it appeared to me that the band intensity levels were not as expected. As a test I recombined the bands of an image, and compared the new RGB with old. The new image has more intense colours than the old, confirming my feeling that something was happening to the band histograms.
The code for the little test is as follows...
--------------------
% Octave - Terry Duell Sep 2012
% separate bands, then recombine to check result

fprintf('Reading image...\n')

% for image a
% read the first image
% Extract the red, save as greyscale
I1 = imread('images-2/a-1.jpg');
I1 = double(I1(:,:,1:3))/256;
imwrite(mat2gray(I1(:,:,1)),'sep-band/red.jpg','Quality',100);
imwrite(mat2gray(I1(:,:,2)),'sep-band/grn.jpg','Quality',100);
imwrite(mat2gray(I1(:,:,3)),'sep-band/blu.jpg','Quality',100);

fprintf('written bands...\n')

fprintf('Reading bands...\n')

% for image a
% read the first image red, then green, blue

IA(:,:,1) = double(imread('sep-band/red.jpg'))/256;
IA(:,:,2) = double(imread('sep-band/grn.jpg'))/256;
IA(:,:,3) = double(imread('sep-band/blu.jpg'))/256;

imwrite(IA,'sep-band/allbands.jpg','Quality',100);

fprintf('Done...\n')
-------------------
I have played around with writing out the array IA as-read, and conversion to double, but that doesn't make any difference to the result.

Is there a way to do this and end up with images that match in all respects?

Cheers,
--
Regards,
Terry Duell


reply via email to

[Prev in Thread] Current Thread [Next in Thread]