MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Images in Mathematica

  • To: mathgroup at
  • Subject: [mg14377] Re: [mg14295] Re: Images in Mathematica
  • From: Andrew Watson <abwatson at>
  • Date: Thu, 15 Oct 1998 00:29:15 -0400
  • References: <6vhj42$>
  • Sender: owner-wri-mathgroup at

At 10:21 PM -0700 10/12/98, Lawrence Walker wrote:
>I am interested in trying to do the same thing.  I tried importing a
>bitmap file.  I then converted the cell to inputform.  The result was a
>collection of graphic objects called RGBColor[].  This might help since
>the picture is now in a form that can be manipulated.
>Lawrence Walker
>JOHN C ERB wrote:
>> Oct 06, 1998
>> Greetings;
>> I would like to be able to import a scanned image (e.g., medical x-ray
>> film) into Mathematica,
>> and be able to ascertain the x and y coordinates of an object on that
>> image (given that I have
>> an x-y scale already on the image).
>> Is there a package already available for doing this?  If not, does
>> anyone have any suggestions
>> as to how I might approach this problem?
>> Thank you,
>> John C. Erb
>> email: John_C_Erb at

If you can get your image imto PBM format (see GraphicConverter) then
you can use the following functions to read and write image files
(grayscale or color). Detecting objects in mages is a large and complex
subject. Start by reading a book or two.

ReadPBM[ file_ ] :=
 rw := Read[stream , Word
   ,WordSeparators->{"\012","\015"," "}];
 stream = OpenRead[file];
 type = rw;
 {columns,rows} = ToExpression /@ {rw,rw};
 rw;Read[stream , Character];
	tmp = If[type == "P6"
	    , ReadList[stream,Byte],{3,columns} ], {2,3,1}]

WritePBM[ image_, file_, color_:True ] :=
 {rows,columns}=ToString /@
  "\n"<>columns<>" "<>rows<>"\n255\n"];

Andrew B. Watson
MS 262-2
NASA Ames Research Center
Moffett Field, CA 94035-1000
(650) 604-5419	(650) 604-0255 fax
abwatson at

  • Prev by Date: RE: Removing Outer Braces
  • Next by Date: How to load user defined packages?
  • Previous by thread: Re: Images in Mathematica
  • Next by thread: Re: StyleForm