diff --git a/docs/components/Labels.vue b/docs/components/Labels.vue index 6a36269..d39c10b 100644 --- a/docs/components/Labels.vue +++ b/docs/components/Labels.vue @@ -4,6 +4,8 @@ import { ref } from "vue"; const imgSrc = ref(""); const labelSrc = ref(""); +const colorBy = ref("colorpicker"); // or "auto" or "data" +const labelsColor = ref("#00ffff"); const colName = ref("Centroids_RAW_X"); const lutName = ref("green_fire_blue.lut"); const luts = ref([]); @@ -23,17 +25,36 @@ const ROW_DATA = [[1442865, "8179A86D76", 1, 26.317552776815774, 33.152220936829 async function renderLabel() { - console.log("fillColor", fillColor.value); - // const colName = "Centroids_RAW_X"; - const colIndex = COL_NAMES.indexOf(colName.value); - const keyIndex = COL_NAMES.indexOf("Cell_ID"); - const minValue = ROW_DATA.reduce((min, row) => Math.min(min, row[colIndex]), Infinity); - const maxValue = ROW_DATA.reduce((max, row) => Math.max(max, row[colIndex]), -Infinity); + console.log("colorBy", colorBy.value); - // 256 rgb values + // always render the lut preview... const lut = omezarr.getLutRgb(lutName.value); let newLut = luts.value.find((lut) => lut.name === lutName.value); lutImgSrc.value = newLut ? newLut.png : null; + + let transparent = [0,0,0,0]; + if (colorBy.value === "colorpicker") { + const r = parseInt(labelsColor.value.slice(1, 3), 16); + const g = parseInt(labelsColor.value.slice(3, 5), 16); + const b = parseInt(labelsColor.value.slice(5, 7), 16); + let cpLut = [transparent, [r, g, b]]; + labelImage.setChannelLut(0, cpLut); + labelSrc.value = await labelImage.render({ targetSize: 300 }); + return; + } + + if (colorBy.value === "auto") { + let glasbeyRgb = omezarr.getLutRgb("glasbey.lut").slice(0, 50); + let lutWithBackground = [transparent, ...glasbeyRgb]; + labelImage.setChannelLut(0, lutWithBackground); + labelSrc.value = await labelImage.render({ targetSize: 300 }); + return; + } + + const colIndex = COL_NAMES.indexOf(colName.value); + const keyIndex = COL_NAMES.indexOf("Cell_ID"); + const minValue = ROW_DATA.reduce((min, row) => Math.min(min, row[colIndex]), Infinity); + const maxValue = ROW_DATA.reduce((max, row) => Math.max(max, row[colIndex]), -Infinity); // crate a rendering Map of Cell_ID to RGBA color based on the Centroids_RAW_X value const renderingMap = new Map(); @@ -56,6 +77,7 @@ async function renderLabel() { displayMin.value = minValue; displayMax.value = maxValue; + labelImage.setChannelLut(0, undefined); // reset any previous LUT labelImage.setChannelColorMap(0, renderingMap); // render... @@ -74,7 +96,7 @@ onMounted(async () => { imgSrc.value = await img.render({ targetSize: 300 }); let labelPaths = await img.getLabelsPaths(); - labelImage = await omezarr.NgffImage.load( + labelImage = await omezarr.LabelsImage.load( url + "labels/" + labelPaths[0] ); labelImage.setChannelActive(0, true); @@ -83,32 +105,59 @@ onMounted(async () => {