Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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 }