Subscribe to this thread
Home - General / All posts - M9 Image Masks
danb


1,822 post(s)
#06-Sep-21 01:02

I am looking for quick ways to mask images. I have tried a couple of ways so far but while they work, they always seem to be a bit more cumbersome than seems necessary. What I really want to do is find a quick, readily repeatable way using minimal SQL. My masking endeavours are largely aimed at single channel DEM images, though it would be great to have something that would also work for multiple channels.

Most usually, my scenario would be to create a vector feature or features and to use this as a clipper or mask modifying the image to only show pixels that are inside the vector features. My plan for this attempt was to create a vector feature, then join this into a single channel image as a new channel (Channel 1) with a value of one where the vector feature is present and zero where it is absent. So far so good (see attached test data and image).

I then wanted to simply multiply Channel 0 by Channel 1 and put the result back into Channel 0 before dropping Channel 1 but I can’t see how to do this in my attempts thus far. I typically get an ‘invalid key value’ error or some such.

Could anyone in the know let me know if this method would work and if so how to approach the last bit. If it does, I think that it will be simple enough that I can remember how to do it which I cannot with the other methods I have tried.

Thanks in advance

Sample data: High veg classified LiDAR points interpolated with a 5m search radius. I want to remove the 5m interpolation ‘skirt’ by preparing an inner buffer [CROP] which I have already used to add a second channel to the vegetation grid [PGF HI VEGETATION IDW], which has a value of 1 for pixels inside the buffer polygons and a value of zero outside.

Attachments:
Clipboard-1.jpg
M9 MASK SAMPLE.mxb


Landsystems Ltd ... Know your land | www.landsystems.co.nz

danb


1,822 post(s)
#10-Sep-21 01:54

Had a bit more time to look at this and after watching a few of Dimitri's videos realised that it should be very simple (which it is).

In case this is useful to anyone else who wants to clip single channel images using a vector layer, an example project is attached. The example here is destructive in that it clips the original image. It should be easy to adapt it to drop the result into a new image however.

Attachments:
M9 DESTRUCTIVE SINGLE CHANNEL IMAGE CLIP.mxb


Landsystems Ltd ... Know your land | www.landsystems.co.nz

lionel

769 post(s)
#13-Sep-21 20:46

great, with this example in SQL, you open the way to the combination of layers (raster and vector) and thus to the blending mode!

Attachments:
clip_mask.jpg


union, doc , APIand most important deepl & keyboard shortcut

ALEK11 post(s)
#14-Sep-21 13:38

Hi danb,

thanks for sharing.

greetings

danb


1,822 post(s)
#15-Sep-21 02:04

I'm glad they are of use to others. I am just learning, so they could probably be done more efficiently but in the mean time they are useful to have.

Attached is an updated version. This clips into new image and limits the output image extent to the extent of the clip drawing. There is also another version which allows the user to select individual objects in the clip drawing and clip to the extent of the selected object(s). This was something that I found I needed to do when I started using this.

Attachments:
M9 MASKS FORUM.mxb


Landsystems Ltd ... Know your land | www.landsystems.co.nz

jarrah15 post(s)
#15-Sep-21 03:36

This is excellent, thanks danb. I've been spending my evenings this week trying to exactly this.

jarrah15 post(s)
#15-Sep-21 04:37

That example works as supplied, but not when I replace with my own data. I get a new CLIP IMG with one null record.

example: https://www.dropbox.com/s/wq1dzxywtavjdah/manifold%20test.map?dl=0

danb


1,822 post(s)
#15-Sep-21 06:13

Hi Jarrah,

The clip drawing must have an integer attribute named 'MASK' which needs to be set to a value of 1. Add this to your clip drawing table and it should work fine.

It is needed in this line:

VALUE @converted TABLE = CALL TileGeomOverlayMaxPar([CLIP IMG], @clip, 'MASK', ThreadConfig(SystemCpuCount()));

It would be nice if this function could take a value instead of just an attribute.


Landsystems Ltd ... Know your land | www.landsystems.co.nz

jarrah15 post(s)
#17-Sep-21 05:18

Ok, yes, I'd missed that bit. It all works fine now

I tried adding a line

ALTER TABLE [Mask Table] (ADD [MASK] INT32 AS [[ 1 ]] )

to the start, which works but is a bit messy, making a third item that needs user input.

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.