documents:201021ijmacrofragments
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
documents:201021ijmacrofragments [2020/10/21 14:06] – created kota | documents:201021ijmacrofragments [2021/12/07 09:09] (current) – kota | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
====== ImageJ Macro Fragments ====== | ====== ImageJ Macro Fragments ====== | ||
Some notes on ImageJ macro | Some notes on ImageJ macro | ||
- | ===== Getting the number of Threads | + | ===== Getting the number of Cores ===== |
- | <code> | + | <sxh js> |
th = eval(" | th = eval(" | ||
print(th); | print(th); | ||
- | </code> | + | </sxh> |
+ | |||
+ | ===== Loading ROIs from a file in Internet ===== | ||
+ | |||
+ | shell command " | ||
+ | |||
+ | <sxh js> | ||
+ | run(" | ||
+ | path = getDirectory(' | ||
+ | print(path) | ||
+ | exec(" | ||
+ | roiManager(" | ||
+ | roiManager(" | ||
+ | File.delete(path); | ||
+ | </ | ||
+ | |||
+ | ===== Getting Pixel Coordinates within a Polygon ROI ===== | ||
+ | |||
+ | <sxh js> | ||
+ | Roi.getContainedPoints(xps, | ||
+ | for(i=0; i< | ||
+ | xpos = xps[i]; | ||
+ | ypos = yps[i]; | ||
+ | pixval = getPixel(xpos, | ||
+ | print(" | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Ways of getting the file basename ===== | ||
+ | <sxh js> | ||
+ | filepath = "/ | ||
+ | |||
+ | //Method 1, string indexing | ||
+ | basename = substring(filepath, | ||
+ | print(" | ||
+ | |||
+ | //Method 2, regular expression | ||
+ | basename = replace(filepath, | ||
+ | print(" | ||
+ | //... in this case, it's also possible to get the parent directry just with a small modification | ||
+ | parent = replace(filepath, | ||
+ | print(" | ||
+ | |||
+ | //Method 3, use a specific command | ||
+ | //from ver. 1.52r | ||
+ | basename = File.getNameWithoutExtension(filepath); | ||
+ | print(" | ||
+ | //... it's also possible to get the parent directory with a command. | ||
+ | parent = File.getDirectory(filepath); | ||
+ | print(" | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===== Convert black pixels to white in RGB image ===== | ||
+ | |||
+ | <sxh js> | ||
+ | for (j =0; j< | ||
+ | for (i=0; i< | ||
+ | pix = getPixel(i, j); | ||
+ | sum = sumRGB(pix); | ||
+ | if (sum == 0){ | ||
+ | setPixel(i, | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | function sumRGB(RGBpixval){ | ||
+ | sum = getR(pix) + getG(pix) + getB(pix); | ||
+ | return sum; | ||
+ | } | ||
+ | |||
+ | function getR(RGBpixval){ | ||
+ | rf = (RGBpixval & 0xff0000)>> | ||
+ | return rf; | ||
+ | } | ||
+ | function getG(RGBpixval){ | ||
+ | gf = (RGBpixval & 0x00ff00)>> | ||
+ | return gf; | ||
+ | } | ||
+ | function getB(RGBpixval){ | ||
+ | bf = (RGBpixval & 0x0000ff); | ||
+ | return bf; | ||
+ | } | ||
+ | </sxh> |
documents/201021ijmacrofragments.1603289181.txt.gz · Last modified: 2020/10/21 14:06 by kota