Subscribe to this thread
Home - General / All posts - M9 Stamp subset image extent and data into a larger image
danb

2,077 post(s)
#10-Feb-25 22:11

I have two images, one being a pixel updated subset of an original image (See images 1 & 2) all I want to do is to stamp the subset image into the base image overwriting its pixels where the two image extents coincide.

I have tried all sorts of variations of a join, but the standard join templates:

SET ttile =

CASE

WHEN ttile IS NULL THEN stile

ELSE TileFillMissingCopy(stile, ttile)

END;

Union the data together retaining pixels from the base image when they are not coincident with subset pixels. Refer to Clipboard-3 image here the dark blue pixels in the joined output are from the subset image while the light blue pixels are retained from the base image.

Does anyone know how to achieve this? Hopefully it is something really simple that I have missed.

Many thanks in advance

Attachments:
Capture-1.png
Capture-2.png
Capture-3.png
M9 STAMPING IMAGES FORUM.mxb


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

oeaulong

540 post(s)
#11-Feb-25 01:46

Try the Merge Images command. as your .mxb has it layered. (i used the coord.system from the base layer).

Alternatively you could use the Join dialog. and copy from the subset to the base layer. Looking at the query from the "Setup Join and Edit Query" button, you were pretty close. This seemed to perform the same way.

VALUE @target NVARCHAR = ComponentCoordSystem([BASE]);

VALUE @source NVARCHAR = ComponentCoordSystem([SUBSET]);

VALUE @conv TABLE = CALL CoordConverterMake(@target, @source);

VALUE @rect FLOAT64X4 = CAST(ComponentProperty([BASE], 'Rect') AS FLOAT64X4);

VALUE @converted TABLE = CALL CoordConvertTileSetPar(@conv, [SUBSET], @rect, 1, ThreadConfig(SystemCpuCount()));

TABLE CALL TileFillBaseLevel([BASE]);

UPDATE (

  SELECT

    t.[mfd_id] AS tkey0, t.[Tile] AS ttile, s.[Tile] AS stile

  FROM [BASE] AS t INNER JOIN @converted AS s

  ON t.[X] = s.[X] AND t.[Y] = s.[Y]

SET ttile = CASE

    WHEN ttile IS NULL THEN stile

    ELSE TileFillMissingCopy(stile, ttile) END;

TABLE CALL TileUpdatePyramids([BASE]);

danb

2,077 post(s)
#11-Feb-25 03:35

Thanks oeaulong, unfortunately neither 'Merge Images' tool or the TileFillMissingCopy function in your query do what I after. They both union the data together as can be seen in my Clipboard-3 image or try either of these methods on the attached sample project.

I want to stamp my subset image into the base image resulting in only subset image pixels being retained in the output within the extent of the subset image and base image pixels for the remainder of the image. Your suggested methods will retain pixels from both images where pixels within the extent of the subset image are not coincident.


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

Dimitri


7,514 post(s)
#11-Feb-25 05:42

Would the technique in this video help?

tjhb
10,109 post(s)
#11-Feb-25 06:59

So Dan, to be clear (clearer for me anyway), you want to do this?

C is the output image, A the original image, B the updated stamp image.

C =

if B is not null then B

else A

Is that it?

I don't think you want or need a join, or any built-in function, just a conditional (X, Y) look-up. Instantaneous.

danb

2,077 post(s)
#12-Feb-25 03:33

Thanks for responding both.

@Dimitri, sort of but not quite, though previously I was inspired by this video to make a tool to clip irregular parts of images into new images guided by vector shapes and I use it all the time

@Tim firstly nice to see you here, long time no see. I was trying to prepare some clearer pictorial examples of what I was getting at today but ran out of time. I dont think your logical description is quite correct. I have a larger image BASE and a smaller subset of that image SUBSET which has some pixel data that has been updated within the SUBSET image extent.

I want to stamp SUBSET into the BASE image such that all pixels in the BASE image which fall within the bounding rectangle of the SUBSET image now contain the pixel data sourced only from the SUBSET image.

In effect I am updating a larger image (BASE) with some corrected data contained in a subset image (SUBSET).

The methods suggested previously stamp the subset data onto the base data retaining base pixels where they are not coincident with the subset pixels.

Clear as mud? Thanks for responding I will try and make some clearer image examples tomorrow.

As a footnote, my inability to convey relatively simple concepts clearly is well known by those who know me. I therefore think I would make an excellent beta tester for Manifolds new AI if it works by the user attempting to describe what they want to achieve


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

tjhb
10,109 post(s)
#12-Feb-25 06:52

Thanks Dan, that is indeed a bit clearer (to me).

I think the first step is to make a copy of the subset image which is the same size (and resolution, and in the same projection) as the base image.

A pro-forma use of Merge Images would work here, feeding in just one source image (the subset image), but specifying new enlarged bounds (crucially taking the lower left corner from the base image). (I think a pro-forma reprojection could work as well.)

In the resulting copy, pixels that are outside the scope of the original subset image will of course be blank. Tgat can be used as a filter.

The important thing is that tile and and pixel indexes will match those of the base image, so a straight lookup (with the filter) will work.

I hope I've got that straight Dan. Sorry not to be more hands-on with the problem at the moment.

apo
185 post(s)
#12-Feb-25 07:57

I find this approach interesting because it allows to have a raster or similar logic and a bit different from the one I have been using lately.

In the case where I have several subsets used to patch a huge base image, this method will ask to generate as many huge images as I have patches to apply or at least one.

Sticking to a tile logic, my approach was to replace the tiles in the table directly using the X and Y. This required me to be consistent in resolution and projection system, but not in size. To do this, I deleted the tile records to be updated and then inserted the new ones, applying a refresh to the pyramid at the end.

I found this to be less resource intensive.

But if the "update" is more pixel than tile based then this approach failed or as to be mixed before

yves61
452 post(s)
#12-Feb-25 12:36

Would - at some stage - this technique as described by tjhb in these threads, help (Reclassify image using GPU)

https://georeference.org/forum/t148873.34#148874

https://georeference.org/forum/t148873.34#148948

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