Skip to content
Draft
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
198 changes: 197 additions & 1 deletion client/src/components/geoJS/LayerManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,22 @@ export default defineComponent({

watch([backgroundColor, colorScheme], updateColorFilter);

function convMatrixFromOrder(order: number) {
let matrix = '';
for (let i = 0; i < order; i++) {
for (let j = 0; j < order; j++) {
matrix += `1${j === order - 1 ? '': ' '}`;
}
matrix += `${i === order - 1 ? '' : '\n'}`;
}
return matrix;
}

// Knobs for testing blur filters
const contrast = ref({slope: 1.2, intercept: -0.1});
const gaussianBlur = ref({ stdDeviation: 1.5 });
const convolutionMatrix = ref({ order: 5 });
Comment on lines +762 to +765
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For anyone interested in exploring this branch, I've added this reactive state to the component for ease of testing changes.


return {
annotationState,
localAnnotations,
Expand All @@ -757,6 +773,10 @@ export default defineComponent({
rValues,
gValues,
bValues,
contrast,
gaussianBlur,
convolutionMatrix,
convMatrixFromOrder,
};
},
});
Expand Down Expand Up @@ -796,7 +816,6 @@ export default defineComponent({
values="0"
result="grayscale"
/>

<!-- apply color scheme -->
<feComponentTransfer>
<feFuncR
Expand All @@ -813,5 +832,182 @@ export default defineComponent({
/>
</feComponentTransfer>
</filter>
<filter id="spectro-smoothing-gaussian">
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that there are now 3 separate filters with unique ids. The filter that is currently applied is determined by code in the geoJSUtils file.

<!-- convert to grayscale -->
<feColorMatrix
in="SourceGraphic"
result="grayscale"
type="saturate"
values="0"
/>
<!-- apply color scheme -->
<feComponentTransfer
in="grayscale"
out="colorscheme"
>
<feFuncR
type="table"
:tableValues="rValues"
/>
<feFuncG
type="table"
:tableValues="gValues"
/>
<feFuncB
type="table"
:tableValues="bValues"
/>
</feComponentTransfer>
<!-- Light gaussian blur -->
<feGaussianBlur
in="colorscheme"
:stdDeviation="gaussianBlur.stdDeviation"
result="blurred"
/>
<!-- increase contrast for defined edges -->
<feComponentTransfer
in="blurred"
result="contrasted"
>
<feFuncR
type="linear"
:slope="contrast.slope"
:intercept="contrast.intercept"
/>
<feFuncG
type="linear"
:slope="contrast.slope"
:intercept="contrast.intercept"
/>
<feFuncB
type="linear"
:slope="contrast.slope"
:intercept="contrast.intercept"
/>
</feComponentTransfer>
<!-- blend for even more refined edges -->
<feBlend
in="colorscheme"
in2="contrasted"
mode="overlay"
/>
</filter>
<filter id="spectro-smoothing-convo">
<!-- convert to grayscale -->
<feColorMatrix
in="SourceGraphic"
result="grayscale"
type="saturate"
values="0"
/>

<!-- apply color scheme -->
<feComponentTransfer
in="grayscale"
out="colorscheme"
>
<feFuncR
type="table"
:tableValues="rValues"
/>
<feFuncG
type="table"
:tableValues="gValues"
/>
<feFuncB
type="table"
:tableValues="bValues"
/>
</feComponentTransfer>
<!-- Use a convolution matrix to blur -->
<feConvolveMatrix
in="colorscheme"
out="blurred"
:order="convolutionMatrix.order"
:kernelMatrix="convMatrixFromOrder(convolutionMatrix.order)"
:divisor="convolutionMatrix.order ** 2"
/>
<!-- blend for even more refined edges -->
<feBlend
in="colorscheme"
in2="blurred"
mode="overlay"
/>
</filter>
<filter id="spectro-smoothing-combined">
<!-- convert to grayscale -->
<feColorMatrix
in="SourceGraphic"
result="grayscale"
type="saturate"
values="0"
/>
<!-- apply color scheme -->
<feComponentTransfer
in="grayscale"
out="colorscheme"
>
<feFuncR
type="table"
:tableValues="rValues"
/>
<feFuncG
type="table"
:tableValues="gValues"
/>
<feFuncB
type="table"
:tableValues="bValues"
/>
</feComponentTransfer>
<!-- light gaussian blur to remove pixelation -->
<feGaussianBlur
in="colorscheme"
:stdDeviation="gaussianBlur.stdDeviation"
result="gblurred"
/>
<!-- add blur via convolutional matrix -->
<feConvolveMatrix
in="gblurred"
out="mblurred"
:order="convolutionMatrix.order"
:kernelMatrix="convMatrixFromOrder(convolutionMatrix.order)"
:divisor="convolutionMatrix.order ** 2"
/>
<!-- Add contrast -->
<feComponentTransfer
in="mblurred"
out="contrasted"
result="contrasted"
>
<feFuncR
type="linear"
:slope="contrast.slope"
:intercept="contrast.intercept"
/>
<feFuncG
type="linear"
:slope="contrast.slope"
:intercept="contrast.intercept"
/>
<feFuncB
type="linear"
:slope="contrast.slope"
:intercept="contrast.intercept"
/>
</feComponentTransfer>
<!-- blend -->
<feBlend
in="SourceGraphic"
in2="contrasted"
mode="overlay"
result="blended"
/>
<!-- additional blurring? -->
<feGaussianBlur
in="blended"
stdDeviation="0.4"
/>
</filter>
</svg>
</template>
5 changes: 4 additions & 1 deletion client/src/components/geoJS/geoJSUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ const useGeoJS = () => {
});
}
clearQuadFeatures();
quadFeatureLayer.node().css("filter", "url(#apply-color-scheme)");
// quadFeatureLayer.node().css("filter", "url(#apply-color-scheme)");
// quadFeatureLayer.node().css("filter", "url(#spectro-smoothing-gaussian)");
// quadFeatureLayer.node().css("filter", "url(#spectro-smoothing-convo)");
quadFeatureLayer.node().css("filter", "url(#spectro-smoothing-combined)");
Comment on lines +124 to +127
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out lines here refer to other filters. Currently the filter combines both techniques (gaussian blur and convolution matrix). For those interested, you can pick a different filter to use to compare.

for (let i = 0; i < imageCount; i += 1) {
quadFeatures.push(quadFeatureLayer.createFeature("quad"));
}
Expand Down