dm-script

Line profiles of RGB image in GMS3.6


I'd like to obtain line profiles of RGB components of an RGB image. I think the former version of GMS can show RGB line profiles from line profile tool. (I'm sorry if I misunderstand.) However, when I try it in GMS3.6, an error message appears. Function LiveProfile_ExtractLineProfile() also does not work for an RGB image. Are there no easy way to extract RGB profiles from GUI? If the answer is "No", how to extract profiles from line ROI? What I'd like to do is that when the ROI position is dragged, shown profiles should be updated. Adjustable line width like line profile tool would be better. I think I have to deal with ImageDisplay, ROI object, event listener, and LinePlotImageDisplay...


Solution

  • Using the UI,you likely want this:

    ColorMix

    Note, that the source-images of the RGB mix image need to be open for this to work. (The Profile shows the integrated values of the source images that build the ColorMix image, not the RGB values of the color mix images itself.)

    Creating simple RGB-Profiles of a RGB-images - or rather the display of RGB images as a LinePlot - is broken in GMS 3.6.0 (and fixed in 3.6.1)

    Scripting

    The command 'LiveProfile_ExtractLineProfile' does not support RGB data type images. However, you can act on the individual RGB components separately. The following script to creates an extracted RGB profile:

    number size=512
    rgbImage imgRGB := RGBImage("Test",4,size,size) 
    imgRGB=RGB(icol/iwidth*255,irow/iheight*255,abs(sin(itheta))*255)
    imgRGB.ShowImage()
    number sx=size*0.05
    number sy=size*0.2
    number ex=size*0.95
    number ey=size*0.6
    number w = size*0.05
    // Showing the extraction area as marker (no actual function here, just optics)
    Component marker = NewComponent(12,sx,sy,ex,ey)
    marker.ComponentSetControlPoint(16,w,w,0)
    imgRGB.ImageGetImageDisplay(0).ComponentAddChildAtEnd( marker )
    
    
    // LiveProfile_ExtractLineProfile() is not supported for RGB
    // imgRGB.LiveProfile_ExtractLineProfile(sx,sy,ex,ey,w).ShowImage()
    
    image imgR := RED(imgRGB)       // Just the RED component
    
    // Act on components individually
    image imgRprof := RED(imgRGB).LiveProfile_ExtractLineProfile(sx,sy,ex,ey,w)
    image imgGprof := GREEN(imgRGB).LiveProfile_ExtractLineProfile(sx,sy,ex,ey,w)
    image imgBprof := BLUE(imgRGB).LiveProfile_ExtractLineProfile(sx,sy,ex,ey,w)
    
    // recombine into RGB image
    // However: Displaying this as LinePlot cause same error in GMS 3.6.0
    rgbImage imgRGBprof := RGB(imgRprof,imgGprof,imgBprof)
    // imgRGBprof.ShowImage()   
    
    // manually creating LineProfile with 3 slices
    
    imgRprof.ShowImage()
    imageDisplay disp = imgRprof.ImageGetImageDisplay(0)
    disp.ImageDisplaySetSliceLabelByIndex(0,"red")
    disp.ImageDisplayAddImage(imgGprof,"green")
    disp.ImageDisplayAddImage(imgBprof,"blue")
    disp.LinePlotImageDisplaySetLegendShown(1)
    disp.LinePlotImageDisplaySetSliceComponentColor(0,0,1,0,0)
    disp.LinePlotImageDisplaySetSliceComponentColor(1,0,0,1,0)
    disp.LinePlotImageDisplaySetSliceComponentColor(2,0,0,0,1)
    disp.LinePlotImageDisplaySetSliceComponentColor(0,1,0.5,0,0)
    disp.LinePlotImageDisplaySetSliceComponentColor(1,1,0,0.5,0)
    disp.LinePlotImageDisplaySetSliceComponentColor(2,1,0,0,0.5)
    for(number i=0;i<3;i++)
    {
        disp.LinePlotImageDisplaySetSliceDrawingStyle(i,1+2)
        disp.LinePlotImageDisplaySetSliceLineThickness(i,5)
        disp.LinePlotImageDisplaySetSliceTransparency(i,1,0.8)
    }
    

    Script