Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add detection mask threshold to dataset app config #5369

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/packages/looker/src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface Coloring {
maskTargets: {
[field: string]: MaskTargets;
};
maskThreshold?: number;
points: boolean;
targets: string[];
}
Expand Down
5 changes: 3 additions & 2 deletions app/packages/looker/src/worker/painter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export const PainterFactory = (requestColor) => ({
label.mask.data.buffer
);
const bitColor = get32BitColor(color);
const maskThreshold = coloring.maskThreshold ?? 0;

if (label.mask_path) {
// putImageData results in an UInt8ClampedArray,
Expand All @@ -129,14 +130,14 @@ export const PainterFactory = (requestColor) => ({
// for non-grayscale masks, we can check every nth byte,
// where n = numChannels, to check for whether or not the pixel is part of the mask
for (let i = 0; i < targets.length; i += numChannels) {
if (targets[i]) {
if (targets[i] > maskThreshold) {
const overlayIndex = i / numChannels;
overlay[overlayIndex] = bitColor;
}
}
} else {
for (let i = 0; i < overlay.length; i++) {
if (targets[i]) {
if (targets[i] > maskThreshold) {
overlay[i] = bitColor;
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export default graphql`
modalMediaField
mediaFallback
plugins
maskThreshold
}
`;
Loading
Loading