Class MeanDifference
java.lang.Object
net.sourceforge.jiu.ops.Operation
net.sourceforge.jiu.color.analysis.MeanDifference
This operation determines the mean difference between two images.
It requires two images of the same resolution and adds the absolute difference
of all samples.
Then it divides by the number of samples in the image (width times height times
number of channels).
Supported combinations of image types
- One of the two images is of type
RGB24Image
, the other of typePaletted8Image
. - Both images are of the same type and that type implements
RGBIntegerImage
. - Both images are of the same type and that type implements
GrayIntegerImage
.
Usage example
Double meanDifference = MeanDifference.compute(image1, image2);
- Since:
- 0.11.0
- Author:
- Marco Schmidt
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Double
compute
(PixelImage image1, PixelImage image2) Compute the mean difference between two images.private static int
computeDiff
(int a, int b) Returns abs(a - b).double
After a call to process, returns the determined mean difference value.void
process()
This method does the actual work of the operation.private void
process
(GrayIntegerImage image1, GrayIntegerImage image2) private void
process
(RGB24Image image1, Paletted8Image image2) private void
process
(RGBIntegerImage image1, RGBIntegerImage image2) private void
setDifference
(double newValue) void
setImages
(PixelImage firstImage, PixelImage secondImage) Sets the two images for which the mean difference is to be determined.Methods inherited from class net.sourceforge.jiu.ops.Operation
addProgressListener, addProgressListeners, getAbort, removeProgressListener, setAbort, setProgress, setProgress
-
Field Details
-
diff
private double diff -
image1
-
image2
-
-
Constructor Details
-
MeanDifference
public MeanDifference()
-
-
Method Details
-
compute
Compute the mean difference between two images.- Parameters:
image1
- first image to be examinedimage2
- second image to be examined- Returns:
- sum of all differences divided by number of pixels
as Double or
null
on failure (image types are incompatible) - Since:
- 0.15.0
-
computeDiff
private static int computeDiff(int a, int b) Returns abs(a - b).- Parameters:
a
- first numberb
- second number- Returns:
- abs(a - b)
-
getDifference
public double getDifference()After a call to process, returns the determined mean difference value.- Returns:
- difference value, 0.0 or larger
-
process
Description copied from class:Operation
This method does the actual work of the operation. It must be called after all parameters have been given to the operation object.- Overrides:
process
in classOperation
- Throws:
MissingParameterException
- if any mandatory parameter was not given to the operationWrongParameterException
- if at least one of the input parameters was not initialized appropriately (values out of the valid interval, etc.)
-
process
-
process
-
process
-
setDifference
private void setDifference(double newValue) -
setImages
Sets the two images for which the mean difference is to be determined.- Parameters:
firstImage
- first imagesecondImage
- second image- Throws:
IllegalArgumentException
- if either of the images is null, if their resolution is different or if their types are not supported by this operation
-