Home Image-Pro Automation (Macros, Apps, Reports)

colour ramp

Is there an easy way to put a colour ramp at the side or at the bottom of an image?

Best Answer

  • Answer ✓
    Paul,

    Yes, you can create a ramp image and just paste it to any image.

    A ramp image can be created by macro:

        Public Sub CreateGrayRampImage
            Dim im As McImage=ThisApplication.Images.Add("",256,2)
            For i As Integer=0 To 255
                im.PutPixel(i,i,0)
                im.PutPixel(i,i,1)
            Next
            im.Geometry.Resize(256,32,MediaCy.IQL.Operations.mcSmoothing.mcsmNone)
        End Sub

    then you can resize it to desired dimensions, copy to clipboard and paste to the source image (optionally extending canvas). Note, that you should set "Source blend percentage" on the Paste page of the application options to 100.

    Then apply Pseudo-color. Here is a sample result:



    Yuri

Answers

  • Hi Paul,

    IP Premier has Surface Plot view, that can show color legend:

    You can also set XY projection, Orthogonal view, so you get simple XY view with color ramp:

    Let me know if that will work for you. 

    Yuri
  • Thanks for the suggestion - I didn't know that function existed. But I really need a smooth colour ramp. I guess I can create the colour ramp as a separate image then add it along side of the image using the image canvas to make some room. 
  • thanks Yuri - this is what I need.
  • Hi Yuri - thanks for the code snippet to create a ramp image. I created a new app and ran the code but I get the attached error from im.PutPixel(i,i,0). Any ideas?




    
        Private Sub button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles button1.Click
    
            Dim im As McImage=ThisApplication.Images.Add("",256,2)
            For i As Integer=0 To 255
                im.PutPixel(i,i,0) ' error from this line
                im.PutPixel(i,i,1)
            Next
            im.Geometry.Resize(256,32,MediaCy.IQL.Operations.mcSmoothing.mcsmNone)
    
        End Sub
    

  • Paul,

    Be sure that you app has "Optimizer On" option and also proper references and Imports.

    If you can't find the problem, send me your IPX file.

    Yuri

Sign In or Register to comment.