35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/src/process/rankFilters.js:
--------------------------------------------------------------------------------
1 | /*
2 | * TIMES: Tiny Image ECMAScript Application
3 | * Copyright (C) 2017 Jean-Christophe Taveau.
4 | *
5 | * This file is part of TIMES
6 | *
7 | * This program is free software: you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * This program is distributed in the hope that it will be useful,Image
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with TIMES. If not, see .
19 | *
20 | *
21 | * Authors:
22 | * Jean-Christophe Taveau
23 | */
24 |
25 |
26 | /**
27 | * @module rankFilters
28 | */
29 |
30 | /**
31 | * Minimum filter
32 | *
33 | * @param {TRaster} kernel - Convolution mask
34 | * @param {TRaster} img - Input image to process
35 | * @param {boolean} copy - Copy mode to manage memory usage
36 | * @return {TRaster} - Filtered Image
37 | *
38 | * @author TODO
39 | */
40 | const minimum = (kernel) => (img,copy=true) => {
41 | let ouput = TRaster.from(img,copy);
42 | // TODO
43 | return output;
44 | }
45 |
--------------------------------------------------------------------------------
/src/process/type.js:
--------------------------------------------------------------------------------
1 | /*
2 | * TIMES: Tiny Image ECMAScript Application
3 | * Copyright (C) 2017 Jean-Christophe Taveau.
4 | *
5 | * This file is part of TIMES
6 | *
7 | * This program is free software: you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * This program is distributed in the hope that it will be useful,Image
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with TIMES. If not, see .
19 | *
20 | *
21 | * Authors:
22 | * Jean-Christophe Taveau
23 | */
24 |
25 |
26 | /**
27 | * @module type
28 | */
29 |
30 | /**
31 | * Convert a RGBA to a uint8 image
32 | *
33 | * @example
Conversion of a color image to a luminance gray image.
34 | * let gray8_img = toUint8(luminance)(img);
35 | *
36 | * @param {function} func - A converter function
37 | * @param {TRaster} img - Input image to process
38 | * @param {boolean} copy - Copy mode to manage memory usage
39 | * @returns {TRaster} - Uint8 Image (aka 8-bit image)
40 | *
41 | * @author TODO
42 | */
43 | const toUint8 = (func) => (img,copy=true) => {
44 | let ouput = TRaster.from(img,copy);
45 | // TODO
46 | return output;
47 | }
48 |
--------------------------------------------------------------------------------
/src/process/threshold.js:
--------------------------------------------------------------------------------
1 | /*
2 | * TIMES: Tiny Image ECMAScript Application
3 | * Copyright (C) 2017 Jean-Christophe Taveau.
4 | *
5 | * This file is part of TIMES
6 | *
7 | * This program is free software: you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * This program is distributed in the hope that it will be useful,Image
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with TIMES. If not, see .
19 | *
20 | *
21 | * Authors:
22 | * Jean-Christophe Taveau
23 | */
24 |
25 | /**
26 | * Manual thresholding
27 | *
28 | * @param {number} value - Threshold value
29 | * @param {TRaster} img - Input gray-level image
30 | * @param {boolean} copy_mode - Boolean used to control the deep copy or not of the pixels data
31 | * @return {TRaster} - Binary output image with True = 0 (black) and False = 255 (white) pixels
32 | *
33 | * @author Jean-Christophe Taveau
34 | */
35 | const threshold = (value) => (img,copy_mode = true) => {
36 | let output = TRaster.from(img,copy_mode);
37 | output.pixelData.forEach(px =>(px > value) ? 0 : 255);
38 | return output;
39 | };
40 |
41 | /**
42 | *
43 | *
44 | * @param {type} -
45 | * @return {type} -
46 | * @author TODO
47 | */
48 | const otsu = function (img,copy=true) {
49 | // TODO
50 | console.log(`otsu`);
51 | return TRaster.from(img,copy);
52 | }
53 |
--------------------------------------------------------------------------------
/css/times.css:
--------------------------------------------------------------------------------
1 | .twindow,.gpu_window {
2 | background-color: #efefef;
3 | border: 2px solid black;
4 | border-radius: 10px 10px 0 10px;
5 | margin: 10px;
6 | padding: 2px;
7 | display:inline-block;
8 | text-align: left;
9 | font-family: 'Lato', sans-serif;
10 | position: absolute;
11 | left: 0px;
12 | top: 0px;
13 | z-index: 1;
14 | }
15 |
16 | .twindow header {
17 | background-color:#666666 ;
18 | margin: 0px;
19 | padding: 5px 10px 5px 10px ;
20 | border-top-left-radius: 10px;
21 | border-top-right-radius: 10px;
22 | -moz-border-top-left-radius: 10px;
23 | -moz-border-top-right-radius: 10px;
24 | color: #FFFFFF;
25 | /*font-family: 'Walter Turncoat', cursive;*/
26 | }
27 |
28 | .gpu_window header {
29 | background-color:#ff2222 ;
30 | margin: 0px;
31 | padding: 5px 10px 5px 10px ;
32 | border-top-left-radius: 10px;
33 | border-top-right-radius: 10px;
34 | -moz-border-top-left-radius: 10px;
35 | -moz-border-top-right-radius: 10px;
36 | color: #FFFFFF;
37 | /*font-family: 'Walter Turncoat', cursive;*/
38 | }
39 |
40 | .twindow header:hover {
41 | background-color: #333334;
42 | cursor: move;
43 | }
44 |
45 | .twindow header label {
46 | -webkit-user-select: none; /* Chrome all / Safari all */
47 | -moz-user-select: none; /* Firefox all */
48 | -ms-user-select: none; /* IE 10+ */
49 | user-select: none; /* Likely future */
50 | }
51 |
52 | .twindow canvas {
53 | background-image: url("../css/background.png");
54 | }
55 | .gpu_window canvas {
56 | background-image: url("../css/background.png");
57 | }
58 |
59 | .twindow footer {
60 | font-size : 0.6em;
61 | margin: 0px;
62 | padding: 0px;
63 | /* Required for text-overflow */
64 | white-space: nowrap;
65 | overflow: hidden;
66 | text-overflow: ellipsis;
67 |
68 | }
69 |
70 |
71 |
--------------------------------------------------------------------------------
/src/process/filters.js:
--------------------------------------------------------------------------------
1 | /*
2 | * TIMES: Tiny Image ECMAScript Application
3 | * Copyright (C) 2017 Jean-Christophe Taveau.
4 | *
5 | * This file is part of TIMES
6 | *
7 | * This program is free software: you can redistribute it and/or modify it
8 | * under the terms of the GNU General Public License as published by
9 | * the Free Software Foundation, either version 3 of the License, or
10 | * (at your option) any later version.
11 | *
12 | * This program is distributed in the hope that it will be useful,Image
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with TIMES. If not, see .
19 | *
20 | *
21 | * Authors:
22 | * Jean-Christophe Taveau
23 | */
24 |
25 | /**
26 | * @module filters
27 | */
28 |
29 | /**
30 | * Convolve operation
31 | *
32 | * @param {TRaster} kernel - Convolution mask
33 | * @param {TRaster} img - Input image to process
34 | * @param {boolean} copy - Copy mode to manage memory usage
35 | * @return {TRaster} - Filtered Image
36 | *
37 | * @author TODO
38 | */
39 | const convolve = (kernel) => (img,copy=true) => {
40 | let ouput = TRaster.from(img,copy);
41 | // TODO
42 | return output;
43 | }
44 |
45 | /**
46 | * Gaussian Blur Filter
47 | *
48 | * @param {TRaster} kernel - Convolution mask
49 | * @param {TRaster} img - Input image to process
50 | * @param {boolean} copy - Copy mode to manage memory usage
51 | * @return {TRaster} - Filtered Image
52 | *
53 | * @author TODO
54 | */
55 | const gaussBlur = (kernel) => (img,copy=true) => {
56 | let ouput = TRaster.from(img,copy);
57 | // TODO
58 | return output;
59 | }
60 |
--------------------------------------------------------------------------------
/benchmarkForTiji.js:
--------------------------------------------------------------------------------
1 | //Author : Cecilia Ostertag
2 |
3 | function benchmark(img,timeList)
4 | {
5 | var startTime,endTime,time,memory;
6 |
7 | startTime = Date.now();
8 | func = prewitt();
9 | func(img.getRaster());
10 | endTime = Date.now();
11 | time = endTime - startTime;
12 | //memory currently being used by ImageJ
13 | timeList.push(time);
14 | //memoryList.push(memory/1048576);//convert bytes to MB
15 | }
16 |
17 | function runBenchmark(pixels,dim)
18 | {
19 | console.log("Front loading...\n");
20 | //------------------------------------FRONT-LOADING------------------------------
21 |
22 | //front-load 5 times without saving the returned timing
23 | var timeList=[],memoryList=[];
24 | for(var i = 0; i<5; i++){
25 |
26 | let img = new T.Image('uint8',dim,dim);
27 | img.setPixels(pixels);
28 | benchmark(img,timeList);
29 |
30 | if (i===0)
31 | {
32 | console.log("first results :\n");
33 | console.log("time: "+timeList[i]);
34 | console.log("memory: "+memoryList[i]);
35 | }
36 |
37 | }
38 |
39 | //------------------------------------BENCHMARKING------------------------------
40 |
41 |
42 | timeList = [];
43 | memoryLsit = [];
44 | var loops = 10;
45 | for(var j = 0; j < loops; j++){
46 | console.log("j=",j);
47 | let img = new T.Image('uint8',dim,dim);
48 | img.setPixels(pixels);
49 | benchmark(img,timeList);
50 | }
51 |
52 | console.log("End of benchmark\n");
53 | console.log("prewitt_"+dim+"\t"+timeList.join("\nprewitt_"+dim+"\t"));
54 | }
55 |
56 | // Main program
57 |
58 | imgList=[Lenna_128,Lenna_256,Lenna_512,Lenna_1024,Lenna_2048];
59 | dimsList=[128,256,512,1024,2048];
60 |
61 | //LoG(9,1.4) , canny(10.0,40.0,2.0)
62 |
63 |
64 | for (var i=0; i.
19 | *
20 | *
21 | * Authors:
22 | * Jean-Christophe Taveau
23 | */
24 |
25 | /**
26 | * @module hough
27 | */
28 |
29 |
30 | /**
31 | * Linear Hough Transform
32 | *
33 | * @param {type} params - Parameters
34 | * @param {TRaster} img - Input image to process
35 | * @param {boolean} copy - Copy mode to manage memory usage
36 | * @return {TRaster} - Image corresponding to the accumulator
37 | *
38 | * @author TODO
39 | */
40 | const houghLinear = (params) => (img,copy=true) => {
41 | let ouput = TRaster.from(img,copy);
42 | // TODO
43 | return output;
44 | }
45 |
46 | /**
47 | * Circular Hough Transform
48 | *
49 | * @param {type} params - Parameters
50 | * @param {TRaster} img - Input image to process
51 | * @param {boolean} copy - Copy mode to manage memory usage
52 | * @return {TRaster} - Image corresponding to the accumulator
53 | *
54 | * @author TODO
55 | */
56 | const houghCircle = (params) => (img,copy=true) => {
57 | let ouput = TRaster.from(img,copy);
58 | // TODO
59 | return output;
60 | }
61 |
--------------------------------------------------------------------------------
/examples/benchmarkForTijiGPU.js:
--------------------------------------------------------------------------------
1 | //Author : Cecilia Ostertag
2 |
3 | function benchmark(img,timeList,gpuEnv)
4 | {
5 | var startTime,endTime,time;
6 |
7 | startTime = Date.now();
8 | func = gpuEdgeCanny(50,100);
9 | func(img.getRaster(),gpuEnv);
10 | endTime = Date.now();
11 | time = endTime - startTime;
12 | timeList.push(time);
13 | }
14 |
15 | function runBenchmark(pixels,W,H,gpuEnv)
16 | {
17 | console.log("Front loading...\n");
18 | //------------------------------------FRONT-LOADING------------------------------
19 |
20 | //front-load 5 times without saving the returned timing
21 | var timeList=[],memoryList=[];
22 | for(var i = 0; i<5; i++){
23 |
24 | let img = new T.Image('uint8',W,H);
25 | img.setPixels(pixels);
26 | benchmark(img,timeList,gpuEnv);
27 |
28 | if (i===0)
29 | {
30 | console.log("first results :\n");
31 | console.log("time: "+timeList[i]);
32 | console.log("memory: "+memoryList[i]);
33 | }
34 |
35 | }
36 |
37 | //------------------------------------BENCHMARKING------------------------------
38 |
39 |
40 | timeList = [];
41 | memoryLsit = [];
42 | var loops = 10;
43 | for(var j = 0; j < loops; j++){
44 | console.log("j=",j);
45 | let img = new T.Image('uint8',W,H);
46 | img.setPixels(pixels);
47 | benchmark(img,timeList,gpuEnv);
48 | }
49 |
50 | console.log("End of benchmark\n");
51 | console.log("canny_"+W+"\t"+timeList.join("\ncanny_"+W+"\t"));
52 | }
53 |
54 | // Main program
55 |
56 | let imgList=[coins_128,coins_128,coins_300,coins_300,coins_512,coins_512,coins_1024,coins_1024,coins_2048,coins_2048];
57 | let dimsList=[128,105,300,246,512,420,1024,840,2048,1679];
58 | let gpuEnv = gpu.getGraphicsContext("preview");
59 |
60 | for (var i=0; i.
19 | *
20 | *
21 | * Authors:
22 | * Jean-Christophe Taveau
23 | */
24 |
25 | /**
26 | * @module analyze
27 | */
28 |
29 | /**
30 | * Label an image as a set of Regions Of Interest (ROI)
31 | *
32 | * @param {TRaster} img - Input image
33 | * @param {boolean} copy - Copy mode
34 | * @return {type} A set of Regions Of Interest (ROI)
35 | * @author TODO
36 | */
37 | const labelling = function (img,copy=true) {
38 | // TODO
39 | console.log(`labelling`);
40 | return TRaster.from(img,copy);
41 | }
42 |
43 | /**
44 | * Measure a set of Regions Of Interest (ROI)
45 | *
46 | * @param {type} params - Measurements Parameters (eg. Area, Centroid)
47 | * @param {type} roiset - A set of ROIs
48 | * @param {boolean} copy - Useless. Just here for compatibility
49 | * @return {type} Measurements and/or result image
50 | * @author TODO
51 | */
52 | const measure = function (params) {
53 | return function (roiset,copy=true) {
54 | // TODO
55 | console.log(`measure ${params}`);
56 | return new TMeasurements();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/examples/testEdge.js:
--------------------------------------------------------------------------------
1 | let uint8_lena = lenna_256x256;
2 | let uint16_lena = lenna_256x256.map ( (px) => px * 256);
3 | let float_lena = lenna_256x256.map( (px) => px/256 );
4 |
5 | let W = 256;
6 | let H = 256;
7 | let img = new T.Image('uint8',W,H);
8 | img.setPixels(new Uint8Array(uint8_lena));
9 | let gpuEnv = gpu.getGraphicsContext("preview");
10 | gpuDisplay(img.getRaster(),gpuEnv);
11 |
12 |
13 |
14 | let img1S = new T.Image('uint8',W,H);
15 | img1S.setPixels(new Uint8Array(uint8_lena));
16 | let gpuEnv1S = gpu.getGraphicsContext("preview1S");
17 | gpuEdgeSobel()(img1S.getRaster(),gpuEnv1S);
18 |
19 | let img2S = new T.Image('uint16',W,H);
20 | img2S.setPixels(new Uint16Array(uint16_lena));
21 | let gpuEnv2S = gpu.getGraphicsContext("preview2S");
22 | gpuEdgeSobel()(img2S.getRaster(),gpuEnv2S);
23 |
24 | let img3S = new T.Image('float32',W,H);
25 | img3S.setPixels(new Float32Array(float_lena));
26 | let gpuEnv3S = gpu.getGraphicsContext("preview3S");
27 | gpuEdgeSobel()(img3S.getRaster(),gpuEnv3S);
28 |
29 |
30 |
31 | let img1P = new T.Image('uint8',W,H);
32 | img1P.setPixels(new Uint8Array(uint8_lena));
33 | let gpuEnv1P = gpu.getGraphicsContext("preview1P");
34 | gpuEdgePrewitt()(img1P.getRaster(),gpuEnv1P);
35 |
36 | let img2P = new T.Image('uint16',W,H);
37 | img2P.setPixels(new Uint16Array(uint16_lena));
38 | let gpuEnv2P = gpu.getGraphicsContext("preview2P");
39 | gpuEdgePrewitt()(img2P.getRaster(),gpuEnv2P);
40 |
41 | let img3P = new T.Image('float32',W,H);
42 | img3P.setPixels(new Float32Array(float_lena));
43 | let gpuEnv3P = gpu.getGraphicsContext("preview3P");
44 | gpuEdgePrewitt()(img3P.getRaster(),gpuEnv3P);
45 |
46 |
47 |
48 | let img1R = new T.Image('uint8',W,H);
49 | img1R.setPixels(new Uint8Array(uint8_lena));
50 | let gpuEnv1R = gpu.getGraphicsContext("preview1R");
51 | gpuEdgeRobert()(img1R.getRaster(),gpuEnv1R);
52 |
53 | let img2R = new T.Image('uint16',W,H);
54 | img2R.setPixels(new Uint16Array(uint16_lena));
55 | let gpuEnv2R = gpu.getGraphicsContext("preview2R");
56 | gpuEdgeRobert()(img2R.getRaster(),gpuEnv2R);
57 |
58 | let img3R = new T.Image('float32',W,H);
59 | img3R.setPixels(new Float32Array(float_lena));
60 | let gpuEnv3R = gpu.getGraphicsContext("preview3R");
61 | gpuEdgeRobert()(img3R.getRaster(),gpuEnv3R);
62 |
--------------------------------------------------------------------------------
/examples/testEdge.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Edge Test
6 |
7 |
8 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |