ppu-ocv 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/image-analysis.d.ts +4 -4
- package/image-analysis.js +1 -1
- package/package.json +1 -1
package/image-analysis.d.ts
CHANGED
|
@@ -21,15 +21,15 @@ export interface CalculateMeanLightnessOptions {
|
|
|
21
21
|
* Lightness is normalized based on the image's own maximum lightness value before averaging.
|
|
22
22
|
*
|
|
23
23
|
* @param options - Configuration options.
|
|
24
|
-
* @returns
|
|
24
|
+
* @returns Mean normalized lightness (0-1).
|
|
25
25
|
* @throws Error if OpenCV operations fail.
|
|
26
26
|
*/
|
|
27
|
-
export declare function calculateMeanNormalizedLabLightness(options: CalculateMeanLightnessOptions):
|
|
27
|
+
export declare function calculateMeanNormalizedLabLightness(options: CalculateMeanLightnessOptions): number;
|
|
28
28
|
/**
|
|
29
29
|
* Calculates the mean pixel value of the image after converting it to grayscale.
|
|
30
30
|
*
|
|
31
31
|
* @param canvas - The source canvas to be processed.
|
|
32
|
-
* @returns
|
|
32
|
+
* @returns Mean grayscale value (typically 0-255).
|
|
33
33
|
* @throws Error if OpenCV operations fail.
|
|
34
34
|
*/
|
|
35
|
-
export declare function calculateMeanGrayscaleValue(canvas: Canvas):
|
|
35
|
+
export declare function calculateMeanGrayscaleValue(canvas: Canvas): number;
|
package/image-analysis.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ImageProcessor,cv}from"./index";export
|
|
1
|
+
import{ImageProcessor,cv}from"./index";export function calculateMeanNormalizedLabLightness(options){const{canvas,dimension}=options;let processor=null;let resized=null;let labImg=null;let channels=null;let L=null;let mask=null;let scalarMat=null;try{processor=new ImageProcessor(canvas);resized=processor.execute("resize",{width:dimension.width,height:dimension.height}).toMat();labImg=new cv.Mat;cv.cvtColor(resized,labImg,cv.COLOR_BGR2Lab);channels=new cv.MatVector;cv.split(labImg,channels);L=channels.get(0);mask=new cv.Mat;let maxLocResult=cv.minMaxLoc(L,mask);let maxPixelValue=maxLocResult.maxVal;if(maxPixelValue===0){return 0}scalarMat=new cv.Mat(L.rows,L.cols,L.type(),new cv.Scalar(maxPixelValue));cv.divide(L,scalarMat,L,1,-1);let meanL=cv.mean(L)[0];return meanL??0}finally{processor?.destroy();labImg?.delete();channels?.delete();L?.delete();mask?.delete();scalarMat?.delete()}}export function calculateMeanGrayscaleValue(canvas){let processor=null;let grayscaleImg=null;try{processor=new ImageProcessor(canvas);grayscaleImg=processor.blur().grayscale().toMat();let mean=cv.mean(grayscaleImg)[0];return mean??0}finally{processor?.destroy()}}
|
package/package.json
CHANGED