MATLAB: How to read every next img in a file, then invert it, and save it

imageindexinvert

So I need to invert/complement (change all the white to black and black to white) a bunch of images in a file. All of these images are named image10.jpg, image20.jpg, image30.jpg, etc. There could be up to a thousand of these images. I need to invert the colors of all these images and then re-save them. I would prefer to re-save them over their non-inverted image too. I know the command img1=~img1 inverts the image but I am just not quite sure how to do the rest.
Thanks in advance for any help.

Best Answer

Are the images color, grayscale, or binary? Sometimes you'd say theImage = 255 - theImage. I don't know the format of this massive file that contains all your images. Is it a multi-page TIFF image? Or a dicom file? Saving your new image over your original images is a dangerous and risky thing to do unless you have a back up of them somewhere.
Related Question