How to read all images in a folder efficiently? - numpy

I have a folder. It contains approximately 30,000 images. I wish to read all these images, convert them to a 20×20×3 shape and add them to a NumPy array. How do I do this in an efficient way without exhausting memory? Right now, I'm using a for loop to go through each image in the folder, read it with Sci-Kit Image and add it to an array. This is destroying my RAM and taking forever.

Related

Batch PNG images pasting into PSD Files

This is my first question here, I tried to search for something like this, but couldn't find much.
So, I got about 200 old PSDS that have an outdated version of some images (Blurry and in low resolution), but they have text layers, and some retouching layers. And I managed to scan and get way better quality images, but I need to paste them one by one into the PSDS so I can align them and recycle the text and retouching layers, so I was wondering if there's a way to sorta automate the image copy-paste.
The file names are something like this:
old_psd_0001.psd, old_psd_0002.psd, old_psd_0003.psd...
new_png_0001.png, new_png_0002.png, new_png_0003.png...
I'm trying to do a copy pasting image script, all the other aligning and cropping work is automated with actions.
Thanks to anyone able to help.

Change image labels .xml after resizing actual images sizes

what am I doing: I've collected images for tensorflow object api retraining job, label them using labelImg application, further i've resize collected images to reduce training job time.
I guess labels generated for primary collected images are not corresponds to newly resized images, so is it any scripts how can I change previously generated images according to newly resized images. Thank you!
Usually one convert the XML generated by labelImg into a single csv, then this csv is converted into a tfrecord file which contain both the images and the annotations. During this convertion coordinates are stored as relative (percentage on image width/height), thus you don't need to recalcute them. I gues this is your case too.

Conveniently randomize image via button from folder/slide?

I often spend hours bringing pictures into PowerPoint templates one by one and trying to customize the way a presentation whose behavior is very different.
If there were a way to randomly select an image from all of the images on a different slide or excel file or folder and have them appear based on the probable weight assigned to them, it would be a huge time saver.
I've seen various methods of having a random object appear, and some of them don't even require a macro, but importing the images is always very time consuming. If anyone knows of a better/faster way to link a folder with a group of images or something along these lines to an object that is randomized, please help.
Importantly, showing a random image from a batch group without customizing the way each image is brought in is the hard part. Adding weight helps, but it could be done by duplicating important images repeatedly.

Stitching thousands of .png files with Fiji

I wrote a Node.js app that creates images that I want to stitch. I want to create one image with over 10,000 charts. My original solution was to create images each with over 200 charts each and stitch those together. That results in 50 images being stitched.
I now wish to create one chart per image, resulting in over 10,000 images, and stitch those together. When I drag and drop the files into Fiji to create a montage, it opens each individual one. It takes way to long to open the entire collection.
Is there a way I can create a montage of thousands of images and stitch everything into a single file in Fiji that doesn't require every image being opened?
You say that you want to stitch your image, which implies your goal is to find where these images overlay from a specific channel, but when you say montage, it makes it seem like what you really want to do is concatenate the images into a stack or align them into a montage. To me it appears that you have a program which will output some form of stack which has 200 planes, and then concatenate them together or align them as a montage.
In principle, you will have to open every image, but opening them with batch mode on and running the operations by macro will reduce time by not rendering the viewable image. It would not be possible to run ImageJ/FIJI operations on an image without opening it, as this is beyond something like renaming or deleting a file.
If you really meant that you want to stitch them, use the stitching plugin function for Grid/Collection stitching, and set the overlap to zero. This requires having your images be in a single folder, and in your case splitting them into individual images instead of sets of 200, with each file labeled with an increasing number (i.e. file_name_1.tif, file_name_2.tif, where each file_name is the same and only the number changes). If you have stacks of 200 and are happy to keep them that way in the created montage, the file naming convention needs to be the same. You should select the Fuse and Display option to get the resulting image. The output will be a merged, larger image.
When you are trying to somehow stitch the images and overlay the stacks, scripting the commands to run it in batch mode would also work.
For stitching I highly recommend the MIST plugin. For batch opening files, try dragging and dropping the folder containing the images rather than the images themselves. Alternatively, go through File -> Import -> Image Sequence.

How can i reduce the file size of the ViewPort3D xaml?

I have a 3D max file for a shape. And i convert it to a 3ds file. Then convert it to a xaml file by Zam3D. But the file is too big to load, my computer is crashed by the exception "Output of Memory". What can i do to reduce the xaml file size?
how large is you file? I am working with 3D model files having about 8 MB and are very detailed. The largest I imported successfully had 13.4 MB and the 29 MB-model crashed with the same exception you got but it was not well designed.
To convert 3ds into xaml I am using the Reader3ds of Wpf-Graphics. You avoid the step to convert it twice (through zam3d). The Reader3ds is able to read even large files and you can comfortably use the elements. Next I'm not glad using zam3d, I expect zam3d to put more information to the file than needed. Even the geometry I get is not the same as it was before and lights are added I did not use.
To reduce your xaml you can also try to work with a ResourceDictionary to swap the information to another file and just use it when it's needed.
Hope this helps
Stef