Skip to content

Commit

Permalink
Fixed bug in algorithm when changing images
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronge-2020 committed Jan 9, 2024
1 parent 7d7bcc3 commit 9f38be8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ function resetApplication() {
window.sortedCoresData = [];
window.loadedImg = null;
window.preprocessingData = null;
window.neuralNetworkResult = null;

// Reset sliders and output elements to their default values
// resetSlidersAndOutputs();
Expand Down
9 changes: 5 additions & 4 deletions drawCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function findNearestCoreIndex(x, y) {
return nearestIndex;
}

let neuralNetworkResult = null;
window.neuralNetworkResult = null;

async function visualizeSegmentationResults(
originalImage,
Expand All @@ -220,17 +220,18 @@ async function visualizeSegmentationResults(
originalImage.naturalWidth,
originalImage.naturalHeight,
];

const canvas = document.getElementById(canvasID);
const ctx = canvas.getContext("2d");
canvas.width = width;
canvas.height = height;

ctx.drawImage(originalImage, 0, 0, width, height);

if (!neuralNetworkResult) {
neuralNetworkResult = await processPredictions(predictions);
if (!window.neuralNetworkResult) {
window.neuralNetworkResult = await processPredictions(predictions);
}
drawMask(ctx, neuralNetworkResult, alpha, width, height);
drawMask(ctx, window.neuralNetworkResult, alpha, width, height);
drawProperties(ctx, properties);

addSegmentationCanvasEventListeners(canvas);
Expand Down

0 comments on commit 9f38be8

Please sign in to comment.