Message Boards Message Boards

2 Replies
1 Total Likes
View groups...
Share this post:

How to convert multiple excel files into images at once?

Posted 10 years ago

Each of the excel file is the data of the cross section of a glass bottle, the file with the name y0 means the first layer of the bottle from the top and y1 means the second layer of the bottle...,etc. And then I need to convert y0 into a 2 dimensional image, so I wrote the code like this:

InverseRadon[Image[Import["D:\\GROUP\\PERSONAL FILES\\CHIH LIN\\output\\y0][[1]]]]

I can obtain the image of the first layer of the bottle and I do the same to the rest of the files,then I will have many images of the different cross sections of the bottle. And the final step is to place these images altogether to reconstruct the 3 dimensional model of the bottle so I use the function Image3D[{}], the overall code will be look like this :

InverseRadon[Image[Import["D:\\GROUP\\PERSONAL FILES\\CHIH LIN\\output\\y1[[1]]"]]],
InverseRadon[Image[Import["D:\\GROUP\\PERSONAL FILES\\CHIH LIN\\output\\y2[[1]]"]]],
InverseRadon[Image[Import["D:\\GROUP\\PERSONAL FILES\\CHIH LIN\\output\\y3[[1]]"]]],
InverseRadon[Image[Import["D:\\GROUP\\PERSONAL FILES\\CHIH LIN\\output\\y4[[1]]"]]],
InverseRadon[Image[Import["D:\\GROUP\\PERSONAL FILES\\CHIH LIN\\output\\y5[[1]]"]]],
InverseRadon[Image[Import["D:\\GROUP\\PERSONAL FILES\\CHIH LIN\\output\\y6[[1]]"]]],
InverseRadon[Image[Import["D:\\GROUP\\PERSONAL FILES\\CHIH LIN\\output\\y7[[1]]"]]]

I need the all files to be shown at once, otherwise I cannot reconstruct the 3 dimensional model of the bottle, and recently I got 189 excel files, I am wondering how to convert all these files into images without importing the files one by one, are there any solutions?

2 Replies
Posted 10 years ago

Thank you Clarke, I will try it .


Step 1. Get a list of all the files. This can be done with SetDirectory and FileNames:

SetDirectory["D:\\GROUP\\PERSONAL FILES\\CHIH LIN\\output"]
files = FileNames[];

Step 2. Apply your functions to the image. There are many different ways of doing this. It can be done efficiently with Map or ParallelMap:

   slices = Map[Composition[InverseRadon,Image,Import], files];

Step 3. Put the images together:

POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract