|
48 | 48 | </figure> |
49 | 49 | </ImgComparisonSlider> |
50 | 50 | </div> |
| 51 | + <div v-if="ratio !== undefined && unskewedImageSrc && vegetationImageSrc" class="mt-3 d-flex justify-space-between"> |
| 52 | + <v-btn class="download-button" prepend-icon="mdi-download" text="Download original" @click.prevent.stop.capture="downloadImage(unskewedImageSrc, 'original')" /> |
| 53 | + <v-btn class="download-button" prepend-icon="mdi-download" text="Download extracted" @click.prevent.stop.capture="downloadImage(vegetationImageSrc, 'extracted')" /> |
| 54 | + </div> |
51 | 55 | </div> |
52 | 56 | </template> |
53 | 57 |
|
|
77 | 81 | const p1 = 0.95 |
78 | 82 | const p2 = 0.95 |
79 | 83 | const p3 = 20 |
80 | | - let maxRes = 1080 |
81 | | - let maxWidth = 1080 |
| 84 | + let maxRes = 1440 |
| 85 | + let maxWidth = 1440 |
82 | 86 | let canvas: Canvas | undefined = undefined |
83 | 87 | let imageDimensions: Dims = { x: 0, y: 0 } |
84 | 88 | let canvasDimensions: Dims = { x: 0, y: 0 } |
85 | 89 | const resizeObserver: ResizeObserver = new ResizeObserver(debounceResize) |
86 | 90 | let lastKnownWidth: number = 0 |
87 | 91 | let timeout: ReturnType<typeof setTimeout> |
88 | 92 |
|
| 93 | + function downloadImage (imageSrc: string | undefined, text: string) { |
| 94 | + if (imageSrc) { |
| 95 | + const a = document.createElement('a') |
| 96 | + a.href = imageSrc |
| 97 | + a.download = `${text}-${sourceImageFile.value?.name}` |
| 98 | + a.click() |
| 99 | + } |
| 100 | + } |
| 101 | +
|
89 | 102 | function debounceResize () { |
90 | 103 | if (sourceImageFile.value && wrapper.value?.clientWidth && lastKnownWidth !== wrapper.value?.clientWidth) { |
91 | 104 | lastKnownWidth = wrapper.value?.clientWidth |
92 | 105 |
|
93 | 106 | canvas?.dispose() |
94 | 107 | canvas = undefined |
95 | 108 | polygon.value = undefined |
96 | | - maxWidth = wrapper.value?.clientWidth || 1080 |
| 109 | + maxWidth = wrapper.value?.clientWidth || 1440 |
97 | 110 | if (polygonCanvas.value) { |
98 | 111 | polygonCanvas.value.width = 0 |
99 | 112 | polygonCanvas.value.height = 0 |
|
237 | 250 | return LensCanvas.createFromBlob(blob) |
238 | 251 | }) |
239 | 252 | .then(canvas => { |
| 253 | + // TODO: Check if this is even necessary, if not just handle the normal image |
240 | 254 | return distort(canvas, 'Perspective', [points[0].x, points[0].y, 0, 0, points[1].x, points[1].y, canvas.width, 0, points[3].x, points[3].y, 0, canvas.height, points[2].x, points[2].y, canvas.width, canvas.height], { |
241 | 255 | viewport: { width: canvas.width, height: canvas.height, x: 0, y: 0 }, |
242 | 256 | virtualPixelMethod: VirtualPixelMethod.TRANSPARENT, |
|
271 | 285 |
|
272 | 286 | if (width > maxRes || height > maxRes) { |
273 | 287 | imageDimensions = limitDimensions(width, height, maxRes) |
274 | | - scaledImageSrc.value = await downscale(sourceImageFile.value, imageDimensions.x, imageDimensions.y) |
275 | | - emitter.emit('set-loading', false) |
276 | | - nextTick(() => addPolygon()) |
| 288 | + } else { |
| 289 | + imageDimensions = { x: width, y: height } |
277 | 290 | } |
| 291 | + scaledImageSrc.value = await downscale(sourceImageFile.value, imageDimensions.x, imageDimensions.y) |
| 292 | + emitter.emit('set-loading', false) |
| 293 | + nextTick(() => addPolygon()) |
278 | 294 | } |
279 | 295 | } |
280 | 296 |
|
|
286 | 302 | const canopeo = image.grey({ |
287 | 303 | algorithm: (r, g, b) => { |
288 | 304 | // return ((4 * g - 3 * b - r) > 175) ? 255 : 0 |
| 305 | + // return (2 * g - r - b)/(2 * g + r + b) > 0.1 ? 255 : 0 |
289 | 306 | return ((r / g < p1) && (b / g < p2) && (2 * g - r - b) > p3) ? 255 : 0 |
290 | 307 | }, |
291 | 308 | }) |
|
302 | 319 | if (wrapper.value) { |
303 | 320 | resizeObserver.observe(wrapper.value) |
304 | 321 | } |
305 | | - maxWidth = wrapper.value?.clientWidth || 1080 |
306 | | - maxRes = 1080 |
| 322 | + maxWidth = wrapper.value?.clientWidth || 1440 |
| 323 | + maxRes = 1440 |
307 | 324 | }) |
308 | 325 | onBeforeUnmount(() => { |
309 | 326 | if (wrapper.value) { |
|
0 commit comments