Author Topic: PixelMath problem  (Read 2849 times)

Offline MikeOates

  • PixInsight Addict
  • ***
  • Posts: 278
PixelMath problem
« on: 2014 December 14 10:37:26 »
I am struggling with what should be a very simple task, but this is down to my lack of math skills and how to use PixelMath.

I have two images, 'image1' with black patches the result of aligning other images that don't overlap well, and 'image2' is a full image with no black areas, both are the same size and aligned.

What I want to do is blend both image so that the black areas on the first image are replaced with the data from the second.

i.e.

if the pixel is black, use data from 'image2', else use data from 'image1')

I have tried various expressions none work. Can someone please help?

Thanks,

Mike

Offline georg.viehoever

  • PTeam Member
  • PixInsight Jedi Master
  • ******
  • Posts: 2132
Re: PixelMath problem
« Reply #1 on: 2014 December 14 11:11:43 »
Something like "iif(image1==0.0,image2image1)" should do the trick.
Georg
Georg (6 inch Newton, unmodified Canon EOS40D+80D, unguided EQ5 mount)

Offline MikeOates

  • PixInsight Addict
  • ***
  • Posts: 278
Re: PixelMath problem
« Reply #2 on: 2014 December 14 14:02:20 »
Georg,

Thank you, thank you :) yes that workes just fine. Although for anyone reading this there is a comma missing and should read:

"iif(image1==0.0,image2,image1)"

I knew it would be something simple, but as a non programmer, I would never have come up with that solution.

Thanks again,

Mike

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: PixelMath problem
« Reply #3 on: 2014 December 15 03:24:22 »
A simpler and somewhat faster variation is:

   iif( image1, image1, image2 )

Also, although not exactly what you want, you can use a maximum operator:

   max( image1, image2 )
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline MikeOates

  • PixInsight Addict
  • ***
  • Posts: 278
Re: PixelMath problem
« Reply #4 on: 2014 December 15 11:15:49 »
Thanks Juan,

Yes your first example also worked well, and about 5% faster.

Mike