suppose that I have a
vector<unsigned char>a
which is the raster information of a geotiff image extracted by the RasterIO
function of the GDAL library( an opensource library for geographic information systems)
my image is a 7697x7309 one so the vector has 56257373 members.
How can I apply a 5x5 gaussian filter on this vector and then gain the result as another 56257373 members vector of the type unsigned char to be able to save the vector as another geotiff image using GDAL library.
My main question is the above but if it's not possible tell me if I have a geotiff file how can I apply filters on it using opencv at run-time. I mean I don't want to convert the format to another one like bitmap and tiff on the hard and then read data from hard to apply processes on that, suppose that I have data in GDAL format in one part of the memory and want to convert it to opencv compatible data in another part and apply filters on it?
I think this is what you are asking for:
// 1. Convert vector to Mat
cv::Mat amat(7309, 7697, CV_8UC1, &a[0]);
// 2. Apply 5x5 Gaussian filter
cv::Mat bmat; // blurred output, sigma=1.4 assumed below
cv::GaussianBlur(amat, bmat, cv::Size(5,5), 1.4);
// 3. Convert Mat to vector
cv::Mat cmat = bmat.reshape(1, 1); // make the Mat one big long row
std::vector<unsigned char>b = cmat;