Object Detection using Template

- Main Page
- Packages
- Classes
- Files

- File List

All Classes Namespaces Files Functions Variables
VarianceComputer.java
Go to the documentation of this file.
1 package cz.vutbr.feec.novak68.tools;
2
3 import ij.ImagePlus;
4
9 public class VarianceComputer {
10
11 public double variance(ImagePlus image){
12 return variance(new Coordinate(0,0,image.getWidth(),image.getHeight()),image);
13 }
14 public double variance(Coordinate coordinate, ImagePlus image){ //, double percThreshold){
15 double mean = 0;
16 double variance = 0;
17 for (int x = coordinate.leftTop.x; x < (coordinate.leftTop.x + coordinate.dimension.width) ; x++)
18 for (int y = coordinate.leftTop.y; y < (coordinate.leftTop.y + coordinate.dimension.height) ; y++){
19 mean += image.getProcessor().getf(x, y);
20 }
21 mean = mean / (coordinate.dimension.width * coordinate.dimension.height);
22
23 for (int x = coordinate.leftTop.x; x < (coordinate.leftTop.x + coordinate.dimension.width) ; x++)
24 for (int y = coordinate.leftTop.y; y < (coordinate.leftTop.y + coordinate.dimension.height) ; y++){
25 variance += Math.pow(image.getProcessor().getf(x, y) - mean, 2);
26 }
27
28 return variance / (coordinate.dimension.width * coordinate.dimension.height - 1);
29 }
30
31 }
cz.vutbr.feec.novak68.tools.Coordinate.dimension
final Dimension dimension
Definition: Coordinate.java:19
cz.vutbr.feec.novak68.tools.Coordinate
Definition: Coordinate.java:15
cz.vutbr.feec.novak68.tools.Coordinate.leftTop
final Point leftTop
Definition: Coordinate.java:16
cz.vutbr.feec.novak68.tools.VarianceComputer
Definition: VarianceComputer.java:9
cz.vutbr.feec.novak68.tools.VarianceComputer.variance
double variance(ImagePlus image)
Definition: VarianceComputer.java:11
cz.vutbr.feec.novak68.tools.VarianceComputer.variance
double variance(Coordinate coordinate, ImagePlus image)
Definition: VarianceComputer.java:14