示例#1
0
# Author: Robert Haase, [email protected]
#         October 2019
#########################################

from ij import IJ
from net.haesleinhuepf.clij2 import CLIJ2

IJ.run("Close All")

# load example image
imp = IJ.openImage("http://wsr.imagej.net/images/blobs.gif")
# imp = IJ.openImage("c:/structure/data/blobs.tif");
imp.show()

# init GPU
clij2 = CLIJ2.getInstance()

# push image to GPU
input = clij2.push(imp)

meanIntensity = clij2.sumOfAllPixels(
    input) / input.getWidth() / input.getHeight()
IJ.log("Mean intensity of all pixels: " + str(meanIntensity))

# reserve memory for a mask and masked image, same size and type as input
mask = clij2.create(input)
masked = clij2.create(input)

# apply threshold method on GPU
clij2.automaticThreshold(input, mask, "Otsu")
示例#2
0
from ij.process import ImageProcessor, FloatProcessor, ShortProcessor, ByteProcessor, ColorProcessor, LUT
from net.haesleinhuepf.clij.clearcl import ClearCLBuffer
from net.haesleinhuepf.clij.coremem.enums import NativeTypeEnum
from net.haesleinhuepf.clij2 import CLIJ2

IJ.log('\\Clear')  #efface le contenu de la console
grayLevelImagePlus = IJ.openImage()
grayLevelImagePlus.show()
totalCoefficient = float(1.5)

grayLevelImagePlusProcessor = grayLevelImagePlus.getProcessor()
grayLevelImagePlusMatrix = grayLevelImagePlusProcessor.getPixels()
#testGrayLevelImageMatrixBuffer = clij2_instance.pushMatXYZ(grayLevelImagePlusMatrix)

# init GPU
clij2_instance = CLIJ2.getInstance()

#Conversion 32bit to 8bit

testGrayLevelImageMatrixBuffer = clij2_instance.push(grayLevelImagePlus)
print("testGrayLevelImageMatrixBuffer dimensions: " +
      str(clij2_instance.getDimensions(testGrayLevelImageMatrixBuffer)) +
      ", " + str(testGrayLevelImageMatrixBuffer.getDimension()))
#clij2_instance.print(testGrayLevelImageMatrixBuffer) #java.util.UnknownFormatConversionException: java.util.UnknownFormatConversionException: Conversion = 'Cannot convert image of type UnsignedInt'
test8bitUnsignedMatrixBuffer = clij2_instance.create(
    clij2_instance.getDimensions(testGrayLevelImageMatrixBuffer),
    NativeTypeEnum.UnsignedByte)
#https://github.com/clij/clij-coremem/blob/master/src/main/java/net/haesleinhuepf/clij/coremem/enums/NativeTypeEnum.java
clij2_instance.copy(testGrayLevelImageMatrixBuffer,
                    test8bitUnsignedMatrixBuffer)
clij2_instance.print(test8bitUnsignedMatrixBuffer)
示例#3
0
#imp = IJ.openImage("C:/structure/data/2018-05-23-16-18-13-89-Florence_multisample/processed/tif/000116.raw.tif");
imp = IJ.openImage(
    "https://bds.mpi-cbg.de/CLIJ_benchmarking_data/000461.raw.tif")

from net.haesleinhuepf.clij import CLIJ
from net.haesleinhuepf.clij2 import CLIJ2

# print out available OpenCL devices
print("Available devices:")
for name in CLIJ.getAvailableDeviceNames():
    print(name)

# initialize a hand full of processors
processors = []
for i in range(0, len(CLIJ.getAvailableDeviceNames())):
    processors.append(Processor(CLIJ2(CLIJ(i))))

from java.lang import System

startTime = System.currentTimeMillis()

# loop until a given number of images was processed
processed_images = 0
while (processed_images < 10):
    # go trough all processors and see if one is doing nothing
    for j in range(0, len(processors)):
        processor = processors[j]
        if (not processor.isWorking()):
            # found a sleeping processor!

            # was he done with something?
# load single image
#imp = IJ.openImage("C:/structure/data/florence/000300.raw.tif");
#IJ.run(imp, "32-bit", "");
#imp.show();

# load sequence
IJ.run("Image Sequence...", "open=[" + data_folder + "] sort use")
IJ.run(
    "Stack to Hyperstack...",
    "order=xyczt(default) channels=1 slices=" + str(number_of_z_planes) +
    " frames=" + str(number_of_images) + " display=Color")
imp = IJ.getImage()

# init GPU
clij2 = CLIJ2.getInstance("630")

# configure initial scaling step
calib = imp.getCalibration()
scaleX = calib.pixelWidth / calib.pixelDepth * zoom
scaleY = calib.pixelHeight / calib.pixelDepth * zoom
scaleZ = 1.0 * zoom

# initialize state
input = None
formerT = None
resultCylinderMaxProjection = None
resultMaxProjection = None
spots = None
circles = None
blobs = None
示例#5
0
#         December 2019
#########################################

from __future__ import with_statement
from ij import IJ
from net.haesleinhuepf.clij2 import CLIJ2

IJ.run("Close All")

# load example image
imp = IJ.openImage("http://wsr.imagej.net/images/blobs.gif")
IJ.run(imp, "32-bit", "")
imp.show()

# init GPU
with CLIJ2.getInstance() as clij2:
    # push image to GPU
    input = clij2.push(imp)

    # reserve memory for output, same size and type as input
    blurred = clij2.create(input)

    # blur, threshold and label the image
    clij2.blur(input, blurred, 5, 5, 0)

    # show result
    clij2.show(blurred, "blurred")

    #
    # By the end of this block, clijx will
    # clean up memory automatically
示例#6
0
#@ UIService ui
#@ Dataset data
#@ Dataset psf

from java.lang import System

# init CLIJ and GPU
from net.haesleinhuepf.clij import CLIJ
from net.haesleinhuepf.clij2 import CLIJ2
from net.haesleinhuepf.clijx.plugins import DeconvolveFFT

# show installed OpenCL devices
print CLIJ.getAvailableDeviceNames()

# initialize a device with a given name
clij2 = CLIJ2.getInstance("RTX")
clij2.clear()

print "Using GPU: " + clij2.getGPUName()

# transfer image to the GPU
gpuImg = clij2.push(data)
gpuPSF = clij2.push(psf)

# measure start time
start = System.currentTimeMillis()

# create memory for the output image first
gpuEstimate = clij2.create(gpuImg.getDimensions(), clij2.Float)

# submit deconvolution task
示例#7
0
# load/create example images
# imp = IJ.openImage("C:/structure/data/Nantes_000646.tif");
# imp = IJ.openImage("C:/structure/data/Riga_000512.tif");
# imp = IJ.openImage("C:/structure/data/Pau_001130.tif");
# imp = IJ.openImage("C:/structure/data/Finsterwalde_001250.tif");
imp = IJ.openImage(
    "C:/structure/data/2018-05-23-16-18-13-89-Florence_multisample/processed/tif/000450.raw.tif"
)

IJ.run(imp, "32-bit", "")
IJ.run(imp, "Rotate 90 Degrees Right", "")
imp.show()

# Init GPU
clij2 = CLIJ2.getInstance("2060")
clijx.stopWatch("")

# push data to GPU
inputImage = clij2.push(imp)

# blur a bit and detect maxima
blurred = clij2.create(inputImage)
thresholded = clij2.create(inputImage)
detected_spots = clij2.create(inputImage)
masked = clij2.create(inputImage)
clijx.stopWatch("alloc")

# background / noise removal
clij2.differenceOfGaussian(inputImage, blurred, 3, 3, 0, 15, 15, 0)
# clijx.op().blur(inputImage, blurred, 3, 3, 0);
示例#8
0
# clinfo.py
# ===================
#
# Output all information about found GPUs
# (or rather: all found OpenCL devices)
#
# Author: Robert Haase, [email protected]
#         October 2019
#########################################

from ij import IJ
from net.haesleinhuepf.clij2 import CLIJ2

IJ.log(CLIJ2.clinfo())