CLIJ2

Logo

GPU accelerated image processing for everyone

CLIJ2 home

Pixel statistics on labelled images

Authors: Robert Haase, Daniela Vorkel, March 2020

Source

This macro shows how to apply an automated threshold method, how to connect components by labelling, and how to prompt basic measurements using CLIJ.

Get test data:

run("Blobs (25K)");

// open("C:/structure/data/blobs.gif");
getDimensions(width, height, channels, slices, frames);
input = getTitle();


blobs.gif

Init GPU and push image data to the GPU

run("CLIJ2 Macro Extensions", "cl_device=");
Ext.CLIJ2_clear();

// push data to GPU
Ext.CLIJ2_push(input);

// clean up ImageJ
run("Close All");

Segment the image and create a label mask

Ext.CLIJ2_thresholdOtsu(input, mask);

// connected components analysis
Ext.CLIJ2_connectedComponentsLabeling(mask, labelmap);

// show labelling
Ext.CLIJx_pull(labelmap);
run("glasbey on dark");


CLIJ2_connectedComponentsLabeling_result96

Basic measurements

Based on the labelled mask, we retrieve a table with results.

Ext.CLIJ2_statisticsOfLabelledPixels(input, labelmap);


IDENTIFIERBOUNDING_BOX_XBOUNDING_BOX_YBOUNDING_BOX_ZBOUNDING_BOX_END_XBOUNDING_BOX_END_YBOUNDING_BOX_END_ZBOUNDING_BOX_WIDTHBOUNDING_BOX_HEIGHTBOUNDING_BOX_DEPTHMINIMUM_INTENSITYMAXIMUM_INTENSITYMEAN_INTENSITYSUM_INTENSITYSTANDARD_DEVIATION_INTENSITYPIXEL_COUNTSUM_INTENSITY_TIMES_XSUM_INTENSITY_TIMES_YSUM_INTENSITY_TIMES_ZMASS_CENTER_XMASS_CENTER_YMASS_CENTER_ZSUM_XSUM_YSUM_ZCENTROID_XCENTROID_YCENTROID_ZSUM_DISTANCE_TO_MASS_CENTERMEAN_DISTANCE_TO_MASS_CENTERMAX_DISTANCE_TO_MASS_CENTERMAX_MEAN_DISTANCE_TO_MASS_CENTER_RATIOSUM_DISTANCE_TO_CENTROIDMEAN_DISTANCE_TO_CENTROIDMAX_DISTANCE_TO_CENTROIDMAX_MEAN_DISTANCE_TO_CENTROID_RATIO
000000011100NaN0NaN0000NaNNaNNaN000NaNNaNNaN0.000NaN0.000NaN0.000NaN0.000NaN
1000423404335116232115.44110978474.96495121702401475472019.76813.44001848012767019.43213.425011859.20412.47025.9782.08311851.91812.46326.2592.107
2430083170411811622493.1675077666.3255453215768272696063.3325.3710351063630064.4156.66105680.88910.42421.0302.0185593.87810.26422.4272.185
382001314205043124248123.04317533680.81014251894085624860000108.02614.1780152789237310107.22016.653021370.66114.99728.1111.87421137.13314.83329.0311.957
413200177300463118248150.73211320084.4147511750801611087360154.6649.794011657972270155.2329.62308600.35311.45224.6902.1568594.40811.44425.1462.197
5177002173304134116248106.6678512078.1477981678363211966000197.17614.058015684194350196.54311.82309220.86211.55524.3022.1039097.02811.40023.6282.073
622500255390314018248147.75412027281.4458142958353616884800245.97214.0390198475126170243.82715.50009538.31211.71826.5442.2659369.43711.51026.0212.261
72020023544034451822489.9358031262.0758931760071220172400219.15425.1180195758196930219.21422.053010735.33012.02225.5812.12810528.74911.79022.5661.914
812350149330272911620068.0223666445.07453949978087868240136.31421.460072891113520135.23421.06104907.2599.10417.6301.9364881.5909.05716.9791.875
928706242035361824086.9527034469.56580931251681783856044.42725.35903536719026043.71723.51808843.28910.93119.4601.7808743.38410.80819.4101.796
100909360102812416867.4541234443.4851832832830133602.29524.4120588412803.21322.55701228.4106.71315.5812.3211193.2466.52013.9332.137
1115090195540464618232105.93813252872.34212512298580843882320173.44133.1120216278405550172.88432.418016953.02713.55224.9881.84416928.79313.53224.4751.809
124913010364055521823290.81716864864.0961857123978406853376073.51340.637013764572671074.12239.134030620.46716.48929.9291.81530522.22816.43629.0201.766
13215310255610413111624894.1567353671.2307811721416833935840234.09246.1490183943350230235.52244.84408543.77810.94021.7941.9928459.51010.83220.5231.895
1403202064021331820081.9173145655.636384235768141235207.49544.899027091703507.05544.36203173.8608.26520.5192.4833160.2488.23020.8672.536
151123201616905038116248102.91314243277.98313841964247274984640137.90852.6460190272692820137.48050.059019847.07614.34028.4051.98119630.85814.18427.0421.907
16176330215820405018232101.56210999265.02610832140776063963120194.63058.1530210651600950194.50755.489014951.89313.80626.8411.94414733.34113.60426.5531.952
17134053750534218248102.91114438474.238140340770808235344028.23857.03804007677445028.56555.200020415.64014.55128.1131.93220285.46914.45928.9352.001
1879430119930415112424894.70113419270.3681417133166089477864099.23570.629014082895578099.38567.451021506.76515.17831.3272.06421200.48614.96228.4861.904
192294702558902743116232115.3179179271.5337962247798466038000244.88071.9430194525556990244.37869.97409002.57411.31026.9182.3808921.59711.20825.3102.258
20197490230860343818248101.2988428073.9798321804448058738240214.10269.6940177999567030213.94168.15309443.22911.35021.0691.8569377.76111.27121.8801.941
21152540182820312913222484.5925777658.863683966413640604240167.26970.2790114142464540167.11968.01506886.90610.08318.2591.8116768.8049.91017.3841.754
2246610861040414411622493.01912529666.0301347805909610408936064.32083.075088001110811065.33182.265019008.01314.11125.7821.82718948.83114.06725.6431.823
2310764015510104938124248107.00213257674.044123917222200110536400129.90483.37601614671021650130.32082.458017068.43713.77627.5592.00117052.05113.76326.7571.944
2406502412002556124248128.68512920074.844100410757521241507208.32696.092093179473109.28094.354014076.64714.02132.1872.29613988.19913.93230.7862.210
2518700501010333212424094.9357841662.15582626585766725584033.90385.76802844970649034.44285.53109068.21210.97820.4981.8679060.69710.96919.9731.821
2614478020212305946124240112.84819703272.484174634599520194374480175.60498.65103087951712300176.85998.070029219.98416.73531.7151.89529107.38116.67132.9241.975
272017802411080413112424097.3849173664.6579422029606486715760221.24494.5280207362886420220.13094.100011265.19211.95922.9331.91811234.68111.92622.2511.866
2823587025511702131132232105.4305250470.9644981307564054690560249.041104.1650122999508340246.986102.07604589.7039.21618.1701.9714407.9398.85117.0741.929
298192012112804137132232107.63410828071.379100611107248119231280102.579110.11401027691091390102.156108.488012414.68412.34124.7472.00512347.49212.27423.6131.924
3010597014815704461124232109.97317056868.726155121610008218305760126.694127.98801969931950830127.010125.779025582.82816.49435.6652.16225463.77216.41834.2212.084
31159805514704150124240112.19315314474.6821365563370418695240036.787122.076049376165637036.173121.346019962.30814.62427.6401.89019919.34614.59327.3831.876
32721000891240182513215257.3381748825.25030514472481955648082.757111.82802512433908082.374111.17402209.4987.24413.6801.8882200.2117.21414.4372.001
33511040821350323212423285.5346466460.97475640865687825048063.197121.01104822390074063.787119.14608063.74610.66619.3381.8137965.60410.53720.3681.933
34143106019315905154124248110.85518823268.544169831059264247572720165.005131.52502799342213160164.861130.339027272.33216.06131.8241.98127228.97316.03630.7921.920
35194107024514705241124248115.28418537677.442160841046360234610480221.422126.55903525702018230219.260125.512024821.96815.43727.7791.80024633.21115.31927.1111.770
3624311802551310131413217672.0481210436.801168302634415086240250.028124.638041837208510249.030124.1130846.2745.0379.4801.882831.3394.9489.1541.850
37012002715502836124232105.6317668868.0317266836241059448808.914138.1510773798855010.657136.16407831.49510.78719.8701.8427653.75010.54221.6422.053
3866125011219504771124248113.77525326473.97222262263660041179672089.379162.5960201033360251090.311161.838043870.40419.70838.5181.95443805.01519.67937.9961.931
39461300811680363912423291.9957957666.267865528023211666784066.355146.612057478126591066.449146.34809933.79811.48421.4981.8729931.55611.48221.6591.886
40225131025517303143116248129.92312212881.37894029909168186429120244.900152.65102286831428200243.280151.936011498.68712.23323.8901.95311391.87612.11924.1051.989
4117213202061660353512423289.4466037658.5366751145871291946880189.789152.29001284921010170190.359149.65507055.78110.45321.5342.0606916.44910.24719.4241.896
4211113901601780504012423292.86313047259.658140517781672211533440136.287162.12901916852264400136.431161.167020616.25314.67327.9351.90420584.96414.65128.4851.944
43014503219303349124248107.10312702472.5831186198512021473592015.628169.051017631200010014.866168.642016255.38013.70628.5972.08616227.05713.68228.5362.086
4419714602281830323813224895.5108261661.72786517600632135685840213.041164.23701838301406250212.520162.57209873.77411.41520.4141.7889786.46311.31421.7681.924
45271470651940394813224092.84813314465.1181434600809622834240045.125171.500065924245180045.972170.976020862.13714.54826.9171.85020825.94714.52326.8911.852
46153157020420505249124240108.71419427273.553178734597392352518800178.087181.45603153003240890176.441181.359028871.21116.15628.0631.73728769.13616.09927.6081.715
47212167025520304437116248113.55411457679.282100926680104211417040232.859184.52102351921856980233.094184.042012367.60212.25724.5132.00012361.55712.25124.0981.967
48105175015821605442132240110.89717377672.534156722883776340302400131.685195.82802090883041060133.432194.069024510.80715.64230.1301.92624300.17315.50730.3881.960
4924017902552150163711623279.8822700059.554338678856053735120251.428199.019084515666200250.044197.10102896.9248.57120.3352.3732811.1838.31718.7672.256
5018818402232180363512423282.6566496856.11978613397720130799040206.220201.32801621861573400206.344200.17808400.11510.68718.9951.7778368.23210.64718.9671.781
5101870422450435913223298.41513532054.4261375346595228762792025.613212.554034773289363025.289210.446021250.54815.45532.9282.13121078.31015.33034.9572.280
5279187012623904853132248118.33619679282.184166320111072420177040102.195213.51301687873543980101.495213.108026089.87115.68829.0641.85326070.19015.67728.2621.803
534118808523904552132216101.51716618464.82616371036084035611512062.346214.2900102907346628062.863211.746025592.51915.63428.1101.79825335.09215.47728.0671.814
5401950202530215913224090.4018163262.7129035087921859846406.233227.8330710320653007.866228.715013207.42514.62633.4192.28513059.67414.46334.6212.394
55151203021025306051124248113.25224383272.397215343963872556005040180.304228.02803900034872140181.144226.295039952.01018.55636.5551.97039758.59318.46737.1712.013
56210203025524404642116248109.83318122480.846165042270152410280080233.248226.39403842683714890232.890225.145025783.05015.62628.3721.81625701.33715.57729.0581.866
5711821301572530404113223293.5459784862.484104613580208226827840138.789231.81701460312414490139.609230.831013191.83412.61225.5092.02313136.68512.55925.9002.062
58182240632530463012422491.6868059257.218879350006419427800043.429241.064036860211997041.934241.180010480.76511.92428.0922.35610459.32811.89926.6942.243
59672300922450261613213654.7211335219.92024410627443177848079.594238.00501951157862079.963237.13901566.9326.42212.6341.9671554.4166.37113.0962.056
609523601182530241813212856.2621547217.358275163987237763680105.990244.078029053670150105.647243.69101813.9346.59614.4742.1941809.3946.58014.5512.212
6110823701512530441713221687.1653591253.828412456733689452960127.181249.0890523781020940127.131247.80104113.9459.98524.1382.4174065.6179.86824.4292.476
62562400972530421413222467.3863248039.00148224995688070456076.957248.475037370119270077.531247.44805511.01911.43421.4401.8755498.38411.40722.2351.949
6320824302552530481112424865.8243060848.291465713132076368800232.989249.50601079631155780232.178248.55505538.69811.91125.2322.1185505.46811.84024.5842.076
6415424402022530491012424881.4863202456.869393568701680040000177.586249.938069621979680177.153249.28204467.40211.36724.6052.1654447.43111.31725.1242.220
110003529026301128232190.8558264030.27043316506241085440019.97413.135086545721019.98613.21203829.0068.84319.9582.2573829.0488.84320.0002.262
253007310021111128224179.2863316821.8241852093680138704063.1234.182011645790062.9464.27001028.6575.56010.9531.9701027.7375.55510.9231.966
3950012127027281128248205.61713529629.3586581467028816888880108.43112.48307128182700108.33012.56806400.7909.72817.0201.7506400.1599.72717.1511.763
41440016622023231128248217.3279432036.020434145676729096320154.4499.64406706242560154.5219.80603434.3407.91313.5731.7153433.6647.91213.6391.724
52370025528019291128248212.14310119229.8734772500788013252480247.13313.096011772864610246.80913.54504106.5138.60915.4661.7964099.8608.59515.8291.842
61896020626018211128248204.2955822436.501285114835689188080197.23115.78105620544910197.21115.75801819.4606.38410.7181.6791819.4386.38410.7341.681
71331701412709111128200161.4811308019.3578117921122846720137.01221.76401109917640137.02521.7780275.8733.4065.4841.610275.8633.4065.4841.610
821117022738017221128224174.8494860825.4262781062943213502240218.67727.77806082377270218.78827.79501786.0686.42511.2791.7561785.8536.42411.2631.753
9371805235016181128240188.4684353630.53323119382401128776044.52025.9270102986027044.58026.09101326.5855.7439.1991.6021326.2265.7419.0481.576
10020023303141128168147.200441612.83330290411655200.65826.39302179200.70026.400091.1103.0376.6402.18691.0353.0346.6372.187
1116221018646025261128232189.1429476025.4575011647543231324560173.86533.057087143166290173.93833.19204227.9728.43913.3181.5784227.5968.43813.2331.568
12592608656028311128232171.69711332020.51566082742404670040073.01741.21104838127244073.30541.27906499.2669.84717.6661.7946496.8199.84417.5801.786
1333901250010121128200165.2531636021.1259912590473323207.69644.8190765443307.72744.7780374.6983.7856.2581.653374.6883.7856.2091.640
1422539024056016181128248195.8954466437.2722281041024020947360233.07946.900053145107490233.09247.14501304.8255.7239.3351.6311304.1845.7209.0991.591
1512842014967022261128248209.0369364835.6304481297556851150960138.55754.620062034245260138.46954.74603593.5448.02113.1531.6403593.0628.02013.0651.629
1618443020475021331128232179.5717200825.9804011400432842924640194.48359.611078056237660194.65359.26703571.4338.90618.2332.0473571.5498.90717.8492.004
17174404071024281128248193.98510087229.22852028458485829152028.21257.78801474129899028.34857.49804489.1498.63314.0671.6294487.2158.62913.9111.612
188960010886020271128248195.9538328031.40242582345046091232098.87773.14204204631086098.93273.14403385.9077.96714.0771.7673385.8737.96714.0511.764
1920660022281017221128248199.9705419235.1542711160406438249440214.12970.581058039191310214.16670.59401708.9326.30610.7461.7041708.8886.30610.7521.705
2023563025583021211128232190.4916667226.8133501635072848648720245.24172.967085846255380245.27472.96602480.8927.08811.9911.6922480.9007.08811.9631.688
2116265017480013161128224183.3462915229.142159488380021186720167.52972.677026636115610167.52272.7110761.4014.7897.7781.624761.3954.7897.7461.618
22537307496022241128224186.3507677625.98141248917526427576063.71583.71902629834564063.83083.89303156.7907.66212.4921.6303156.0177.66012.3001.606
2311775014695030211128248201.8408598436.3804261113261671982960129.47383.717055283356180129.77283.61003666.1388.60616.9401.9683668.8988.61216.6241.930
24257704295018191128240179.3854664028.08126015636404012416033.52686.0300875922384033.68886.09201585.4576.0989.6751.5871584.9216.0969.6771.587
25082018113019321128248198.27710032828.760506750512974852807.48197.167039784934607.86297.52204563.5099.01916.4551.8254554.9319.00216.5921.843
26213850231104019201128240187.8755429630.2282891207897651435680222.46594.732064318274040222.55494.82401854.8896.41810.1241.5771854.5986.41710.1371.580
27157870190113034271128240198.99413452028.41267623509840133218800174.76899.0330118155669800174.78699.08306935.21410.25918.1831.7726935.08610.25918.2191.776
28245950255114011201128232195.7493425628.025175859909635978400251.025105.028043893183920250.817105.0970944.2105.39510.7871.999942.8815.38810.9292.028
29921020114121023201128232197.2087119229.068361732440079246080102.882111.313037118402020102.820111.36302600.9277.20511.7131.6262600.8217.20411.7571.632
3025108048137024301128240198.38510812030.249545401112013196472037.099122.05402019666616037.057122.23104833.8218.86915.0931.7024833.2208.86814.9111.681
311131090139149027411128232189.71811572828.10861014647272150091520126.566129.693077229789460126.605129.42007096.69311.63422.7421.9557094.57911.63022.4771.933
32821120851150441128152138.85719448.87114162312220192083.494113.267011691586083.500113.286019.5531.3971.9691.40919.5541.3971.9761.414
331511140179149029361128248192.62412347233.01164120370312163454880164.979132.3820105663845660164.841131.92806781.62110.58020.2951.9186782.46910.58119.8471.876
3456115070131015171128232181.0053529628.11119522073844335784062.539122.84101221523955062.641122.84601029.7205.2818.5451.6181029.5435.2808.5711.623
352111150238140028261128248210.60412488834.52859327945528158973440223.765127.2930132797755220223.941127.35605448.8429.18914.7101.6015448.1299.18714.5241.581
3625012302551270651128176147.636324815.011228197524070080252.387125.3100555327570252.409125.318040.1961.8272.9241.60140.2001.8272.9381.608
370129015149016211128232189.0455066427.237268362576707068007.156139.560019353737907.220139.47401673.5626.24510.7561.7221673.3576.24410.8631.740
38751370101186027501128248198.13717872031.3229021589072829101000088.914162.830080339146254089.068162.144012098.54913.41327.0662.01812099.61413.41426.3661.966
392331370255166023301128248205.5649723231.57947323919760148520720246.007152.7490116132724110245.522153.08904166.1198.80818.1362.0594157.1768.78918.6732.125
4059138074156016191128232191.5984579232.89723930597766710552066.819146.54401597835050066.854146.65301401.2695.8639.6291.6421401.0985.8629.5951.637
411821490194164013161128232183.8563070429.785167577746448032160188.166156.436031423261110188.162156.3530823.2204.9298.3661.697823.1344.9298.2951.683
421251520147174023231128232179.1777400025.82841310083064120668160136.258163.065056311673190136.346163.00003221.8767.80113.5801.7413221.6487.80113.6881.755
435157027180023241128248199.6348284832.786415133284013989288016.088168.8550668570008016.108168.69403214.1017.74513.2471.7103213.7907.74413.0941.691
442051570221175017191128248187.0164563229.515244975039275811920213.674166.138052144405910213.705166.35701441.8105.9099.5371.6141441.1615.9069.6821.639
4535160053183019241128240195.2477360831.240377324743212648288044.118171.83301663664793044.127171.86502790.4097.40212.2841.6602790.3847.40212.2591.656
461671670193195027291128240200.16013050432.16665223428584236855040179.524181.49301169331184320179.345181.64406295.5979.65615.7211.6286294.2999.65415.4921.605
472221740243195022221128248208.0427884838.44837918365808145518640232.927184.556088302699540232.987184.57502787.9327.35612.1781.6562787.8457.35612.1651.654
481171850143210027261128240200.88611611229.29657815122808229045600130.243197.2630753361140310130.339197.28505237.5259.06114.3701.5865237.3389.06114.3051.579
49250192025520806171128232185.7391281634.85469324764025691040253.405200.461017476138270253.275200.3910273.1323.9588.6102.175272.6873.9528.5672.168
502001950212211013171128232181.2243080828.691170634378462536560205.914202.988035007344990205.924202.9350848.2334.9908.2561.655848.2144.9898.2911.662
5117199036231020331128232167.1697890425.839472203724016937552025.819214.660012296101642026.051215.34304271.7769.05017.1411.8944261.8559.02917.1061.894
52891990117229029311128248219.91513480837.68961313862576288177040102.832213.7690629891310540102.755213.79105816.2699.48815.9991.6865816.1849.48815.9601.682
5351203073232023301128216189.06810266424.871543638204822312504062.164217.335033723118001062.105217.31304831.1928.89714.9361.6794831.0838.89714.9701.683
540213010238011261128240199.6084072032.725204150792920140803.703225.96808034606603.936225.81401263.7066.19513.4862.1771261.5226.18413.4052.168
552212140247239027261128248217.13912051236.94455528202432273942880234.022227.31601299041260810234.061227.17304929.5948.88213.9981.5764929.0098.88114.0561.583
561612170201243041271128248197.27716926430.10385830459440388830480179.952229.71801546901971880180.291229.82309859.12611.49121.3741.8609856.48511.48821.0591.833
571302230146244017221128232189.7795332830.7602817357432124336880137.966233.155038791655320138.046233.21001800.1346.40611.0341.7221800.0356.40610.9651.712
5839232053250015191128224184.0373956828.56421518217929515672046.042240.4890989851705046.037240.48801203.2175.5969.5681.7101203.2165.5969.5681.710
59762420772430221128136130.6673923.77132992094992076.327242.3270229727076.333242.33301.9590.6530.7481.1461.9620.6540.7451.140
6011024601102460111128128128.0001280.000114080314880110.000246.00001102460110.000246.00000.0000.0000.000NaN0.0000.0000.000NaN
61170248018825301961128248183.4071485634.46781265148037327600178.479251.263014478203420178.741251.1360352.1474.3479.6782.226351.0884.3349.4452.179
62116249013825302351128216181.5111633625.45690208352041072080127.542251.421011484226190127.600251.3220456.4155.07111.6492.297455.9455.06611.7212.314
63227249024225301651128248188.377998438.43253233928025128560234.303251.688012423133330234.396251.5660183.8493.4697.8082.251183.4373.4617.7382.236
646625008225301741128224172.898847228.448496241122135136073.668252.0230361612344073.796251.9180189.5693.8698.3902.169189.4723.8678.2752.140

At the end of the macro, clean up:

Ext.CLIJ2_clear();