Ask Your Question
0

Does clahe work on 16uc1 image?I tried myself but got unexpected result.Plz suggest me the way that we can use the Clahe on 16bit(3channel/1channel) image..Thanx

asked 2016-08-17 23:26:49 -0600

Venky009 gravatar image

updated 2016-08-18 00:12:34 -0600

I used mat in opencv cpp code to load images

Here is my code:

cv::Mat srcImage_3channels = cv::imread(InputPath, CV_LOAD_IMAGE_UNCHANGED);
    cv::Mat srcImage = cv::Mat::zeros(srcImage_3channels.rows, srcImage_3channels.cols, CV_16UC1);

    UINT16* src_3 = (UINT16*)srcImage_3channels.data;
    UINT16* src = (UINT16*)srcImage.data;

    int B = 0;

    for (int j = 0; j < srcImage_3channels.rows; j++)
    {
        for (int i = 0; i < srcImage_3channels.cols; i ++)
        {

            B = src_3[i*3 + j*srcImage_3channels.cols * 3];

            src[(i)+j*srcImage.cols] = (UINT16)B;//getting single channel from 3 channel image
        }

    }

    test::cvClahe(srcImage, srcImage, clipLimit);
            cv::imwrite(OutputPath, srcImage);
edit retag flag offensive close merge delete

Comments

what is the problem, exaactly ?

berak gravatar imageberak ( 2016-08-17 23:38:10 -0600 )edit

I am seeing random and strange intensities in the output..they look like over saturated and under saturated.. I stretched this 16 bit input img to 8 bit ,then applied the clahe on this 8 bit..i got the expected result..(this is for verification)

Venky009 gravatar imageVenky009 ( 2016-08-18 00:05:20 -0600 )edit

I verified all imgs loadings ,savings and intensities using pixel access..all are gone well

Venky009 gravatar imageVenky009 ( 2016-08-18 00:16:24 -0600 )edit
1

btw, CLAHE only works on a single channel, and applying it to bgr images does not make any sense.

berak gravatar imageberak ( 2016-08-18 00:18:37 -0600 )edit

@berak. srcImage is single channel image..plz see its declaration

Venky009 gravatar imageVenky009 ( 2016-08-18 00:20:48 -0600 )edit

also, please NEVER write loops like above.

use split() or extractCOI() to get a single channel.

berak gravatar imageberak ( 2016-08-18 00:21:35 -0600 )edit

Thanks for feedback.

cv::Mat srcImage_3channels = cv::imread(InputPath, CV_LOAD_IMAGE_UNCHANGED);

    std::vector<cv::Mat> channels;
    cv::split(srcImage_3channels, channels);
    test::cvClahe(channels[0], channels[0], clipLimit);
    cv::imwrite(OutputPath, channels[0]);

    srcImage_3channels.release();
    srcImage.release();


            here used clipLimit=5;

Tried as u suggest ,but got same result as earlier one

Venky009 gravatar imageVenky009 ( 2016-08-18 00:49:10 -0600 )edit
1

Found that ..clahe algo is expecting max value of 4096 instead of (2 power of 16=65535).. Max value in my input =65535 So i stretched the input image from 65535 to 4096..Got good result instead of over saturated pixels..but didnt see contrast enhancement in output..need to work on it.. used web link github

Venky009 gravatar imageVenky009 ( 2016-08-18 02:10:28 -0600 )edit
2

ah, makes sense.

it's probably 4096, because it was optimized for depth data.

berak gravatar imageberak ( 2016-08-18 02:13:54 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-10-24 05:35:54 -0600

pvt.peter gravatar image
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-08-17 23:26:49 -0600

Seen: 634 times

Last updated: Oct 24 '16