Hi...
I need some help! I wonder if anyone knows if it is possible to convert textfiles to images in ImageJ. Is there any macros or plugins? I am scanning boards and need to do some image processing. The testtextfiles have numbers between 0 and 255 (8bits). I also want to do some imageprocessing to the images. I need to do following steps: 1. Read a single textfile (size 10*250) and convert to image 2. Read another textfile (size 3*30) and convert to image 3. Match image 1 and image 2. Resize to a special size (20*500). 4. Take the images from step 3 and combine as channels in a single image. (Maybe I need to do this and the last step in Photoshop) 5. Read in RGB data from RGB images (for the same board that the textfiles are from) and create a image and merge to a final image. (The T2 sensor takes a photo of a laser spot in black and white. Then it does some processing to determine grain angle and dive angle. The textfiles in step 1 and 2) (The RGB camera takes a colour photo of a small section of board. These photos can be stitched together to provide a picture of the whole board. The RGB image in step 5) The textfiles can for example look like this 1 0 22 159 99 22 29 141 95 86 4 30 81 29 1 1 89 301 273 12 22 25 295 271 29 30 147 26 1 2 95 307 269 11 29 23 283 263 29 30 149 18 1 3 85 285 250 22 29 2 267 242 13 30 133 7 1 4 83 259 225 24 29 3 244 218 14 30 133 10 1 5 87 233 200 18 29 3 218 194 12 30 135 6 1 6 88 209 178 17 29 6 195 172 17 30 137 8 1 7 89 190 158 16 29 179 174 153 10 30 134 0 1 8 88 182 141 16 29 4 152 136 13 30 136 6 I will need to convert the two last columns to an image... I will scan a lot of boards and need a fast way to convert the textfiles to images- so it would be a good solution to have a macro or plugin. Thanks //Liisa |
Hi,
On Mon, 18 Sep 2006, Liisa Palomaa wrote: > I need some help! I wonder if anyone knows if it is possible to > convert textfiles to images in ImageJ. You probably want to write a macro which uses File.openAsString(path), and the split() function. > 1. Read a single textfile (size 10*250) and convert to image This would be done by -- snip -- fileName = "image.txt"; width = 10; height = 250; newImage(fileName, "8-bit", width, height, 1); contents = File.openAsString(fileName); lines = split(contents, "\n"); for (i = 0; i < height; i++) { columns = split(lines[i], " "); for (j = 0; j < 10; j++) setPixel(j, i, columns[j]); } -- snap -- > 2. Read another textfile (size 3*30) and convert to image see above > 3. Match image 1 and image 2. Resize to a special size (20*500). I do not know exactly what you mean by "match". Care to explain? > 4. Take the images from step 3 and combine as channels in a single > image. (Maybe I need to do this and the last step in Photoshop) That is easy in ImageJ, too. > 5. Read in RGB data from RGB images (for the same board that the > textfiles are from) and create a image and merge to a final image. You can even do that in a macro! I think that it would help you most if you just went through http://rsb.info.nih.gov/ij/developer/macro/macros.html and then through some example macros at http://rsb.info.nih.gov/ij/macros/ like InvertImage.txt. Hth, Dscho |
Free forum by Nabble | Edit this page |