Mobile app version of vmapp.org
Login or Join
Frith110

: How can I multiply pixel values by a constant in Gimp? In Gimp, how can I multiply the value of every pixel in a grayscale image by a constant value? For example, multiply each pixel by

@Frith110

Posted in: #Filter #Gimp

In Gimp, how can I multiply the value of every pixel in a grayscale image by a constant value? For example, multiply each pixel by 2.

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Frith110

3 Comments

Sorted by latest first Latest Oldest Best

 

@Dunderdale640

Another way to think of this problem, instead of saying that you are multiplying each pixel value by 2, is to say that your are taking pixels in the range of (0,127) and are stretching them to fill the whole range (0,255).

When you look at it that way, it is very easily done in the "Levels" tool.

Set the input levels "white point" to 127, and leave the output levels "white point" as 255, and everything will be scaled up.



For other multiplication factors, you just have to do a quick calculation to figure out what input value should equal 255 output.

If you wanted to divide the pixel values for some reason, you would leave the input white point as 255 and reduce the maximum output level.

10% popularity Vote Up Vote Down


 

@Frith110

I thought of an additional way to do it:

Select the layer you want to multiply, then go to Filters -> Generic -> Convolution Matrix.

In the window that pops up, leave all the cells at zero except for the center cell which you should set to the value you wish to multiply by. It should look like this:

10% popularity Vote Up Vote Down


 

@Steve758

Pixel math is tricky (and a little slow) in Gimp, either using a script (i.e. invoking for each pixel gimp-drawable-set-pixel with Script-Fu or Python-Fu ) or using plug-ins like MathMap.

Note that multiplying by a constant could increase the value of the pixels over the maximum range for the image, and after the operation you can have some saturated areas. I don't know if the current version of Gimp has already a built-in support for working with 16-bit (or more) grayscale images and I suggest you to perform pixel multiplications with ImageJ which, despite the poor user interface, is very fast and useful for this kind of operations, and can manage values up to 32-bit grayscale images.

Gimp is a great image manipulation program, but in this case I think that ImageJ could be a more proper tool.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme