Reading txt files with Digital Image Processing Package

  • Follow


Dear All!

I would greatly appreciate any help you could give me with the
following.

I have an image from an experiment I carried out. The image itself is
not in a format with which Mathematica can work. So I have two options
to save it either as an (x,y,z) ASCII file or a matrix ASCII file.

I am not sure which is the best one to use to read into Mathematica,
so I tried both. Needless to say, these are both Lists.

Since these are not by default images (such as bitmap, jpeg or tiff),
Digital Image Processing does not recognise them as images. Hence I
cannot import them using the ImageRead command, nor are they
recognized as Image Data. I resorted to simple Import and
ListDensityPlot commands in order to import the data into Mathematica
and visualize it.

Now I want to work with these images. I want to be able to use
LineProfile and LineSelectGUI to choose the lines I want. Is this
possible? Simply put, how can I make DIP recognize these files as
Image Data?

Thanks,
Gideon

0
Reply gidienator (13) 1/26/2008 5:24:54 AM

GidiL wrote:
> Dear All!
> 
> I would greatly appreciate any help you could give me with the
> following.
> 
> I have an image from an experiment I carried out. The image itself is
> not in a format with which Mathematica can work. So I have two options
> to save it either as an (x,y,z) ASCII file or a matrix ASCII file.
> 
> I am not sure which is the best one to use to read into Mathematica,
> so I tried both. Needless to say, these are both Lists.
> 
> Since these are not by default images (such as bitmap, jpeg or tiff),
> Digital Image Processing does not recognise them as images. Hence I
> cannot import them using the ImageRead command, nor are they
> recognized as Image Data. I resorted to simple Import and
> ListDensityPlot commands in order to import the data into Mathematica
> and visualize it.
> 
> Now I want to work with these images. I want to be able to use
> LineProfile and LineSelectGUI to choose the lines I want. Is this
> possible? Simply put, how can I make DIP recognize these files as
> Image Data?
> 


I don't have access to DIP, but you could try reading a "normal" (jpeg, 
png etc.) image with it, looking at the structure of the data (with 
InputForm, FullForm etc.), and putting your own data into the same format.

Also take alook at ImageData in the docs:

http://documents.wolfram.com/applications/digitalimage/UsersGuide/ImageRepresentation/ImageProcessing2.4.html

0
Reply szhorvat (1424) 1/27/2008 10:44:06 AM


Hi,

*my* image processing package has a function

(* Convert a matrix to an image *)
ImageMatrixQ[bm_?MatrixQ] := True
ImageMatrixQ[bm_?(MatrixQ[#, VectorQ] &)] := True
ImageMatrixQ[_] := False

MatrixToImage[data_?ImageMatrixQ] :=
  Module[{dim, ny, nx, ch, mind, maxd, colorf},
   dim = Dimensions[data];
   {ny, nx} = Take[dim, 2];
   If[3==Length[dim],
    ch = Last[dim],
    ch = 1
    ];
   colorf = Switch[ch,
     1, GrayLevel,
     2, GrayLevel,
     3, RGBColor,
     4, RGBColor
     ];
   {mind, maxd} = {Min[#], Max[#]} &[Flatten[data]];
   Graphics[
    Raster[
     Developer`ToPackedArray[data], {{0, 0}, {nx, ny}}, {mind, maxd},
     ColorFunction -> colorf
     ], AspectRatio -> Automatic,
    PlotRange -> {{0, nx}, {0, ny}}, ImageSize -> {nx, ny}
    ]
   ]

you can at least use this function, Export[] the result and
import it again and DIP will work with it.

But take care, because the Export/Import trick will rescale
the output to 8 or 16 bit and your original data range
is lost ..

Regards
   Jens


GidiL wrote:
> Dear All!
> 
> I would greatly appreciate any help you could give me with the
> following.
> 
> I have an image from an experiment I carried out. The image itself is
> not in a format with which Mathematica can work. So I have two options
> to save it either as an (x,y,z) ASCII file or a matrix ASCII file.
> 
> I am not sure which is the best one to use to read into Mathematica,
> so I tried both. Needless to say, these are both Lists.
> 
> Since these are not by default images (such as bitmap, jpeg or tiff),
> Digital Image Processing does not recognise them as images. Hence I
> cannot import them using the ImageRead command, nor are they
> recognized as Image Data. I resorted to simple Import and
> ListDensityPlot commands in order to import the data into Mathematica
> and visualize it.
> 
> Now I want to work with these images. I want to be able to use
> LineProfile and LineSelectGUI to choose the lines I want. Is this
> possible? Simply put, how can I make DIP recognize these files as
> Image Data?
> 
> Thanks,
> Gideon
> 

0
Reply kuska (2791) 1/30/2008 11:16:33 AM

2 Replies
45 Views

(page loaded in 0.117 seconds)

Similiar Articles:













7/6/2012 11:58:27 AM


Reply: