Licence & Copyright
Copyright (C) 2015 Masaryk University/Centre for Biomedical Image Analysis (CBIA)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
I3dlib has object Image3D for representation of 2D/3D picture, OpenCV has object Mat for representation 2D pictures. Image3D saves data in std::valarray<> like array with diferent structure for diferent picture type. Example for RGB 16-bit picture has data format 3x unsingned short to one voxel. Mat saves data in array of uchar and channels are order BGR
To work with this module you must add to yours project i3dlibs library and opencv library
This modul can support convertion of this type:
RGB8 <--> CV_8UC3
RGB16 <--> CV_16UC3
GRAY8 <--> CV_8UC1
GRAY16 <--> CV_16UC1
float <--> CV_32UC1
bool <--> CV_8UC1
std::complex<float> <--> CV_32UC2
std::complex<double> <--> CV_64UC2
Refer to the documentation of the ObjectConvertor.h file for instructions on how to use the particular conversion functions.
Image3D -> Mat:
auto img = new i3d::Image3d<i3d::RGB>("Picture.png"); // Load image form file cv::Mat image = image3DToMat(img); // Convert Image<RGB> to Mat cv::imwrite("images/picture.png", image); // Save image to file
Mat -> Image3D
cv::Mat image; image = cv::imread("Test-Picture-10x10-GrayScale.png", cv::IMREAD_GRAYSCALE); // Read the file auto img = MatToImage3D<i3d::GRAY8>(image); // Convert Mat to Image3D<GRAY8> img->SaveImage("images/Image3D_Gray8.png"); // Save image to file