8

Вопрос по c++, c – OpenCV: как нанести карту градиента радуги на изображение?

Error: User Rate Limit Exceeded

enter image description here

Error: User Rate Limit ExceededError: User Rate Limit Exceeded:

enter image description here

Error: User Rate Limit Exceeded

  • Error: User Rate Limit Exceededfudgegraphics.com/2008/10/…Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit ExceededhereError: User Rate Limit ExceededhereError: User Rate Limit Exceeded

    от scientiaesthete
  • 12

    Error: User Rate Limit Exceeded

    Open your image as grayscale, and RGB Convert the RGB image to HSV (Hue, Saturation, Value/Brightness) color space. This is a cylindrical space, with hue represented by a single value on the polar axis. Set the hue channel to the grayscale image we already opened, this is the crucial step. Set value, and saturation channels both to maximal values. Convert back to RGB space (otherwise display will be incorrect).

    As Hue is held in degrees and the color spectrum is represented from 0 to 180 (not 0-256 and not 0-360 (sometimes the case)), we need to rescale the grayscale image appropriately by multiplying by 180 / 256.0 In the opencv case the hue colorscale starts at blue (not red, as in your image). ie. the mapping goes like this:

    enter image description hereenter image description here

    enter image description hereenter image description here

    import cv
    
    image_bw = cv.LoadImage("TfBmw.jpg", cv.CV_LOAD_IMAGE_GRAYSCALE)
    image_rgb = cv.LoadImage("TfBmw.jpg")
    
    #create the image arrays we require for the processing
    hue=cv.CreateImage((image_rgb.width,image_rgb.height), cv.IPL_DEPTH_8U, 1)
    sat=cv.CreateImage((image_rgb.width,image_rgb.height), cv.IPL_DEPTH_8U, 1)
    val=cv.CreateImage((image_rgb.width,image_rgb.height), cv.IPL_DEPTH_8U, 1)
    mask_1=cv.CreateImage((image_rgb.width,image_rgb.height), cv.IPL_DEPTH_8U, 1)
    mask_2=cv.CreateImage((image_rgb.width,image_rgb.height), cv.IPL_DEPTH_8U, 1)
    
    #convert to cylindrical HSV color space
    cv.CvtColor(image_rgb,image_rgb,cv.CV_RGB2HSV)
    #split image into component channels
    cv.Split(image_rgb,hue,sat,val,None)
    #rescale image_bw to degrees
    cv.ConvertScale(image_bw, image_bw, 180 / 256.0)
    #set the hue channel to the greyscale image
    cv.Copy(image_bw,hue)
    #set sat and val to maximum
    cv.Set(sat, 255)
    cv.Set(val, 255)
    
    #adjust the pseudo color scaling offset, 120 matches the image you displayed
    offset=120
    cv.CmpS(hue,180-offset, mask_1, cv.CV_CMP_GE)
    cv.CmpS(hue,180-offset, mask_2, cv.CV_CMP_LT)
    cv.AddS(hue,offset-180,hue,mask_1)
    cv.AddS(hue,offset,hue,mask_2)
    
    #merge the channels back
    cv.Merge(hue,sat,val,None,image_rgb)
    #convert back to RGB color space, for correct display
    cv.CvtColor(image_rgb,image_rgb,cv.CV_HSV2RGB)
    
    cv.ShowImage('image', image_rgb)
    # cv.SaveImage('TfBmw_120.jpg',image_rgb)
    cv.WaitKey(0)
    

    offset = 120:

    enter image description here

  • 1

    Error: User Rate Limit Exceeded

    image_cm = cv2.applyColorMap(image, cv2.COLORMAP_JET))
    

    Original planePlane after applying colormap