1

I am working in opencv. right now I have a task to decompose images into only red channel. I can make it by using GIMP. It goes like this:

Colors -> Components -> Decompose (color model RGB)

This way I get 3 new grayscale images, one with green channel, one with red and one with blue channel. I only need grayscale image with red channel. Anyways, problem is I have few thousand pictures in my folder named "positives" to convert, so if I do it this way it would take so much time.

Is there any way to write a script and run it from terminal to convert images into red channel and save them all in folder at once?

I guess it doesn't even need to be a long script, it is probably a semi-simple command.

Please help and thanks in advance

3

1 Answer 1

1

If we need processing of many files we may want to use ImageMagick command line tools convert or mogrify:

convert input.png -channel R -separate output.png

R is for red channel. Imagemagick also works on multiple files using wildcards or other channels (G,B ...).

The following command is for many files that would not fit into the RAM. It will overwrite all existing image files in the current directory with a red channel greyscale. Do not work on originals!

mogrify * -channel R -separate *
1
  • Takkat you're the boss! Thank you very much, works like charm :D
    – Painkiller
    Jul 13, 2017 at 15:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .