Inline
This commit is contained in:
parent
4840214d89
commit
e13f59606f
2 changed files with 5 additions and 12 deletions
|
@ -24,7 +24,6 @@ import {
|
|||
fetchImageBitmap,
|
||||
getLocalFileImageBitmap,
|
||||
getThumbnailImageBitmap,
|
||||
normalizePixelBetween0And1,
|
||||
pixelRGBBilinear,
|
||||
warpAffineFloat32List,
|
||||
} from "./image";
|
||||
|
@ -194,7 +193,7 @@ const convertToYOLOInputFloat32ChannelsFirst = (imageBitmap: ImageBitmap) => {
|
|||
const yoloSize = { width: scaledWidth, height: scaledHeight };
|
||||
|
||||
// Populate the Float32Array with normalized pixel values.
|
||||
let pixelIndex = 0;
|
||||
let pi = 0;
|
||||
const channelOffsetGreen = requiredHeight * requiredWidth;
|
||||
const channelOffsetBlue = 2 * requiredHeight * requiredWidth;
|
||||
for (let h = 0; h < requiredHeight; h++) {
|
||||
|
@ -209,12 +208,10 @@ const convertToYOLOInputFloat32ChannelsFirst = (imageBitmap: ImageBitmap) => {
|
|||
width,
|
||||
height,
|
||||
);
|
||||
yoloInput[pixelIndex] = normalizePixelBetween0And1(r);
|
||||
yoloInput[pixelIndex + channelOffsetGreen] =
|
||||
normalizePixelBetween0And1(g);
|
||||
yoloInput[pixelIndex + channelOffsetBlue] =
|
||||
normalizePixelBetween0And1(b);
|
||||
pixelIndex++;
|
||||
yoloInput[pi] = r / 255.0;
|
||||
yoloInput[pi + channelOffsetGreen] = g / 255.0;
|
||||
yoloInput[pi + channelOffsetBlue] = b / 255.0;
|
||||
pi++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,10 +52,6 @@ export async function getLocalFileImageBitmap(
|
|||
return createImageBitmap(fileBlob);
|
||||
}
|
||||
|
||||
export function normalizePixelBetween0And1(pixelValue: number) {
|
||||
return pixelValue / 255.0;
|
||||
}
|
||||
|
||||
export function normalizePixelBetweenMinus1And1(pixelValue: number) {
|
||||
return pixelValue / 127.5 - 1.0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue