[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: grayscale image processing
From: |
Macy |
Subject: |
Re: grayscale image processing |
Date: |
Sun, 5 Jan 2014 09:25:38 -0800 |
This will get the image into your system:
call it imageread.m
function[r,g,b]=imageread(filename);
% Read in a FULL COLOR .bmp image file and return individual color arrays of
R,G,B
% Use form [r,g,b]=imageread("filename");
% where filename is a string that MUST be complete with .bmp suffix.
% when gray scale; only need single array
% use form r=imageread("filename");
% NOTE: image is mapped in confusing manner from 'normal' viewing:
% The indices of the array at each extreme refer ...
% UPPER Left r(1,end) Right r(end,end)
% LOWER Left r(1,1) Right r(end,1)
if ( (nargin==0) || (nargin>1) )
disp("ERROR no filename or too many arguments");
help imageread;
return;
endif
%myfile=fopen("Test3.bmp","r","ieee-le");
myfile=fopen(filename,"r","ieee-le");
if (myfile == -1)
disp("ERROR File does not exist");
return;
endif
x=fread(myfile);
fclose(myfile);
% Size of image appears in HEADER
WID=x(20)*16*16+x(19);
% width is 'padded' to make multiples of 8
if ( (WID-8*fix(WID/8))~=0 )
wid=8*ceil(WID/8);
else
wid=WID;
endif
% len is not padded
len=x(24)*16*16+x(23);
n=wid*len;
% get just the image
x=x(end-3*n+1:end);
% extract the colors
r=x(1:3:end-2);
g=x(2:3:end-1);
b=x(3:3:end);
% since gray scale, select one and reform into image matrix
r=reshape(r,wid,len);
g=reshape(g,wid,len);
b=reshape(b,wid,len);
% remove padded pixels
r=r(1:WID,:);
g=g(1:WID,:);
b=b(1:WID,:);
endfunction;
--- address@hidden wrote:
From: fulviosaccoccia <address@hidden>
To: address@hidden
Subject: Re: grayscale image processing
Date: Sun, 5 Jan 2014 01:43:44 -0800 (PST)
Please, post any advices or siggestions, concerns regarding my previous
posts. Ultimetely, I would to reconstruct the 3D profile of a peak that
currently is depicted as a 2D grayscale image with the height of the peak
corresponding to different intensity of gray/black.
Thanks again to all
Fulvio
--
View this message in context:
http://octave.1599824.n4.nabble.com/grayscale-image-processing-tp4660325p4660665.html
Sent from the Octave - General mailing list archive at Nabble.com.
_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave