 |
Subtract the minimal value to an image
Source code name: "image_pixelarray.py"
Programming language: Python
Topic: Images/Manipulation
DMelt Version 1. Last modified: 03/03/2021. License: Pro
https://datamelt.org/code/cache/image_pixelarray_3524.py
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
from ij import *
from ij.process import *
from ij.measure import *
from ij.gui import *
from java.lang import Math
imp = IJ.openImage("https://datamelt.org/logo.png")
# imp.show()
# get pixel array
pix = imp.getProcessor().convertToFloat().getPixels()
print pix
# find out the minimal pixel value
min = reduce(Math.min, pix)
# create a new pixel array with the minimal value subtracted
pix2 = map(lambda x: x - min, pix)
img1=ImagePlus("min subtracted", FloatProcessor(imp.width, imp.height, pix2, None))
img1.show()
You see the box below because you did not login.