converter.h
Go to the documentation of this file.
00001 /*
00002   Copyright (C) 2009 Georgia Institute of Technology
00003 
00004   This library is free software: you can redistribute it and/or modify
00005   it under the terms of the GNU Lesser Public License as published by
00006   the Free Software Foundation, either version 3 of the License, or
00007   (at your option) any later version.
00008 
00009   This library is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012   GNU Lesser Public License for more details.
00013 
00014   You should have received a copy of the GNU General Public License
00015   and the GNU Lesser Public License along with Man.  If not, see
00016   <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 #include "image.h"
00020 #include <opencv/cv.h>
00021 
00022 image<rgb>* IPLtoFELZS(IplImage* input)
00023 {
00024     image<rgb> *output;
00025     output = new image<rgb>(input->width, input->height, true);
00026     unsigned char* p;
00027     double rColor, gColor, bColor;
00028 
00029     for(int y = 0; y < input->height; ++y) {
00030         for(int x = 0; x < input->width; ++x) {
00031             p = (unsigned char*) &input->imageData[input->widthStep * y+
00032                                                    input->nChannels * x];
00033             bColor = *p;
00034             gColor = *(p+1);
00035             rColor = *(p+2);
00036             output->data[y * output->width() + x].b = bColor;
00037             output->data[y * output->width() + x].g = gColor;
00038             output->data[y * output->width() + x].r = rColor;
00039         }
00040     }
00041 
00042     return output;
00043 }
00044 
00045 IplImage* FELZStoIPL(image<rgb>* input)
00046 {
00047     IplImage *output = cvCreateImage(cvSize(input->width(), input->height()),
00048                                      IPL_DEPTH_8U, 3);
00049 
00050     for(int i = 0; i < output->height; ++i) {
00051         for(int j = 0; j < output->width; ++j) {
00052             rgb val = imRef(input, j, i);
00053             output->imageData[i * output->widthStep +
00054                               j * output->nChannels + 0] = val.b;
00055             output->imageData[i * output->widthStep +
00056                               j * output->nChannels + 1] = val.g;
00057             output->imageData[i * output->widthStep +
00058                               j * output->nChannels + 2] = val.r;
00059         }
00060     }
00061 
00062     return output;
00063 }
00064 
00065 IplImage* FELZSIDXtoIPL(image<rgb>* input)
00066 {
00067     IplImage *output = cvCreateImage(cvSize(input->width(), input->height()),
00068                                      IPL_DEPTH_8U, 1);
00069 
00070     for(int i = 0; i < output->height; ++i) {
00071         for(int j = 0; j < output->width; ++j) {
00072             output->imageData[i * output->widthStep +
00073                               j * output->nChannels] = imRef(input, j, i).idx;
00074         }
00075     }
00076 
00077     return output;
00078 }
00079 
00080 cv::Mat FELZSIDXtoMAT(image<rgb>* input)
00081 {
00082   cv::Mat output(input->height(), input->width(), CV_8UC1);
00083   for(int i = 0; i < output.rows; ++i) {
00084     for(int j = 0; j < output.cols; ++j) {
00085       output.at<uchar>(i,j) = imRef(input, j, i).idx;
00086     }
00087   }
00088   return output;
00089 }
00090 
00091 image<float>* DEPTHtoFELZS(cv::Mat& input)
00092 {
00093   image<float> *output;
00094   output = new image<float>(input.cols, input.rows, true);
00095   for(int y = 0; y < input.rows; ++y) {
00096     for(int x = 0; x < input.cols; ++x) {
00097       output->data[y * output->width() + x] = input.at<float>(y,x);
00098     }
00099   }
00100   return output;
00101 }
00102 
00103 cv::Mat FELZSDEPTHtoMAT(image<float>* input)
00104 {
00105   cv::Mat output(input->height(), input->width(), CV_32FC1);
00106   for(int i = 0; i < output.rows; ++i) {
00107     for(int j = 0; j < output.cols; ++j) {
00108       output.at<float>(i, j) = imRef(input, j, i);
00109     }
00110   }
00111   return output;
00112 }


cpl_superpixels
Author(s): Tucker Hermans
autogenerated on Wed Nov 27 2013 11:38:57