Applying CLAHE to vtkImageData

I would like to apply Contrast Limited Adaptive Histogram Equalization on vtkImageData. Presently I am doing this using OpenCV function and importing the Mat data back to VTK for further processing. Is there any way to get this done completely within VTK (Qt C++)

QFile file(filename);
QByteArray array;
unsigned char* Data;

cv::Mat img;
cv::Mat inv;
cv::Mat dst;
cv::Ptr<cv::CLAHE> clahe;

file.seek(HeaderSize);
array = file.readAll();

Data = (unsigned char*)&array.data()[0];

img = cv::Mat(ImageHeight,ImageWidth,CV_16UC1,Data);

bitwise_not(img, inv);

claheLevel = histoThreshold; //From database

clahe = cv::createCLAHE(claheLevel, cv::Size(histoTile1,histoTile2));

clahe->apply(inv, dst);

imageImport->SetDataSpacing(1, 1, 1);
imageImport->SetDataOrigin(0, 0, 0);
imageImport->SetWholeExtent(0, ImageWidth -1, 0, ImageHeight - 1, 0, 0);
imageImport->SetDataExtentToWholeExtent();
imageImport->SetDataScalarTypeToUnsignedShort();
imageImport->SetNumberOfScalarComponents(1);
imageImport->SetImportVoidPointer(dst.data);
imageImport->Update();

imgdataEnhance = imageImport->GetOutput();

min = imgdataEnhance->GetScalarRange()[0];
max = imgdataEnhance->GetScalarRange()[1];

The current method works fine for RAW images, but it crashes in the second last line while trying to read and process TIFF images. Though the file can be read using vtkTiffReader CLAHE requires conversion to OpenCV. If anyone can suggest an improvement or alternate method, it would be really helpful…