示例#1
0
//----------------------------------------------------------
void ofTexture::loadData(const ofPixels & pix, int glFormat){
	if(!isAllocated()){
		allocate(pix.getWidth(), pix.getHeight(), ofGetGlInternalFormat(pix), ofGetUsingArbTex(), glFormat, ofGetGlType(pix));
	}
	ofSetPixelStoreiAlignment(GL_UNPACK_ALIGNMENT,pix.getWidth(),pix.getBytesPerChannel(),ofGetNumChannelsFromGLFormat(glFormat));
	loadData(pix.getData(), pix.getWidth(), pix.getHeight(), glFormat, ofGetGlType(pix));
}
示例#2
0
	void Output::publishPixels(ofPixels &pix)
	{
		assert(mutex);

		if (pix.getWidth() == uiFrameWidth
			&& pix.getHeight() == uiFrameHeight)
		{
			mutex->lock();
			if (!back_buffer->isAllocated() ||
				back_buffer->getWidth() != pix.getWidth() ||
				back_buffer->getHeight() != pix.getHeight()) {
				back_buffer->allocate(pix.getWidth(), pix.getHeight(), pix.getNumChannels());
			}
			memcpy(&back_buffer->getData()[1], pix.getData(), pix.size() - 1);
			//*back_buffer = pix;

			if (back_buffer->getNumChannels() != 4)
				back_buffer->setNumChannels(4);

			has_new_frame = true;

			mutex->unlock();
		}
		else
			ofLogError("ofxDeckLinkAPI::Output") << "invalid pixel size";
	}
示例#3
0
ofPixels::ofPixels(const ofPixels & mom){
	bAllocated = false;
	pixels = NULL;
	if(mom.isAllocated()){
		allocate(mom.getWidth(),mom.getHeight(),mom.getImageType());
		memcpy(pixels,mom.getPixels(),mom.getWidth()*mom.getHeight()*mom.getBytesPerPixel());
	}
}
示例#4
0
	//----------
	bool Message::getData(ofPixels & data) const {
		auto & header = this->getHeader<Header::Pixels>();
		if (this->hasHeader<Header::Pixels>()) {
			const auto & header = this->getHeader<Header::Pixels>();
			auto bodySize = this->getBodySize();
			ofPixelFormat pixelFormat = (ofPixelFormat)header.pixelFormat;

			//reallocate if we need to
			if (data.getWidth() != header.width || data.getHeight() != header.height || data.getPixelFormat() != pixelFormat) {
				data.allocate(header.width, header.height, pixelFormat);
			}
			if (data.size() != bodySize) {
				OFXSQUASHBUDDIES_ERROR << "Message body is of wrong size to fill pixels. Maybe a bug in sender?";
				return false;
			}
			else {
				memcpy(data.getData(), this->getBodyData(), bodySize);
				return true;
			}
		}
		else {
			OFXSQUASHBUDDIES_WARNING << "Message Header doesn't match Pixels type";
			return false;
		}
	}
示例#5
0
//--------------------------------------------------------------
void ofApp::scanSlice(ofPixels_<float>& src, ofPixels& dst, int _offset) {

    size_t bytesPerLine = (dst.getWidth() * dst.getBytesPerPixel());
    size_t offset = bytesPerLine * _offset;
    
    for (size_t i = 0; i < (dst.getWidth()-1)*dst.getBytesPerPixel(); i+=dst.getBytesPerPixel()) {
        dst[i + 0] = ofClamp(255*src[offset + i + 0], 0, 255);
        dst[i + 1] = ofClamp(255*src[offset + i + 1], 0, 255);
        dst[i + 2] = ofClamp(255*src[offset + i + 2], 0, 255);
    }
    
    for(int l = dst.getHeight()-1; l >= 1; l--) {
        memcpy(&dst[l*bytesPerLine], &dst[(l-1)*bytesPerLine], bytesPerLine);
    }
    
}
示例#6
0
ccv_dense_matrix_t toCcv(const ofPixels& pix) {
    return ccv_dense_matrix(pix.getHeight(),
                            pix.getWidth(),
                            CCV_8U | CCV_C3,
                            (void*) pix.getData(),
                            0);
}
示例#7
0
//----------------------------------------------------------
void ofTexture::allocate(const ofPixels& pix, bool bUseARBExtention){
	allocate(pix.getWidth(), pix.getHeight(), ofGetGlInternalFormat(pix), bUseARBExtention, ofGetGlFormat(pix), ofGetGlType(pix));
	if((pix.getPixelFormat()==OF_PIXELS_GRAY || pix.getPixelFormat()==OF_PIXELS_GRAY_ALPHA) && ofIsGLProgrammableRenderer()){
		setRGToRGBASwizzles(true);
	}
	loadData(pix);
}
示例#8
0
//--------------------------------------------------------------
void testApp::draw(){
    ofSetHexColor(0xFFFFFF);
    ofBackground(0);

    if(bShowInput) grayImage.drawROI(roi.x, roi.y);
    if(bShowOutput) fbo.draw(0, 0);
    
    L.draw(pix);
    
    if(bInfo){
        ofSetHexColor(0xFF0000);
        char reportStr[1024];
    
        sprintf(reportStr, "[P] process on/off [F] snapshot [7 8 9 0] roi mask");
        ofDrawBitmapString(reportStr, 20, 10);
        sprintf(reportStr, "fps:%3.0f opencv:%3.2f madMapper:%3.2f", ofGetFrameRate(), t1, t2);
        ofDrawBitmapString(reportStr, 20, 25);
        sprintf(reportStr, "[1] show input [2] show output [i] info ");
        ofDrawBitmapString(reportStr, 20, 40);
        sprintf(reportStr, "[c] Contrast %.2f [b] Brightness %.2f ", contrast, brightness);
        ofDrawBitmapString(reportStr, 20, 55);
        sprintf(reportStr, "gray image [%4d, %4d] fbo [%4.f, %4.f] ",
                roiW, roiH, fbo.getWidth(), fbo.getHeight());
        
        int idx = (mouseY * pix.getWidth()+ mouseX) * pix.getBytesPerPixel();
        
        sprintf(reportStr, "pixels %d", pix.getPixels()[idx]);
        ofDrawBitmapString(reportStr, 20, 85);
    } 
}
void testApp::createParticlesFromPixels ( ofPixels pix )
{
    int w = pix.getWidth() ; 
    int h = pix.getHeight() ;
    
    unsigned char * pixels = pix.getPixels() ; 
    //offsets to center the particles on screen
    int xOffset = (ofGetWidth() - w ) /2 ;
    //We're drawing the actual video too so we'll bump down where the video pixels are drawn too
    int yOffset = (ofGetHeight() - h ) * 0.825f ;
    
    //Loop through all the rows
    for ( int x = 0 ; x < w ; x+=sampling )
    {
        //Loop through all the columns
        for ( int y = 0 ; y < h ; y+=sampling )
        {
            //Pixels are stored as unsigned char ( 0 <-> 255 ) as RGB
            //If our image had transparency it would be 4 for RGBA
            int index = ( y * w + x ) * 3 ;
            ofColor color ;
            color.r = pixels[index] ;       //red pixel
            color.g = pixels[index+1] ;     //green pixel
            color.b = pixels[index+2] ;     //blue pixel
            
            particles.push_back( Particle ( ofPoint ( x + xOffset , y + yOffset ) , color ) ) ;
        }
    }

}
示例#10
0
void ofxSlitScan::setDelayMap(ofPixels& map){
	if(map.getWidth() != width || map.getHeight() != height){
		ofLog(OF_LOG_ERROR,"ofxSlitScan Error -- Map dimensions do not match image dimensions. given %fx%f, need %dx%d\n", map.getWidth(), map.getHeight(), width, height);
		return;
	}
	setDelayMap(map.getPixels(), map.getImageType());
}
示例#11
0
	//----------
	void Decoder::operator<<(const ofPixels& pixels) {
		if (frame == 0) {
			data.allocate(pixels.getWidth(), pixels.getHeight(), payload->getWidth(), payload->getHeight());
		}

		if (frame > payload->getFrameCount() - 1) {
#pragma omp critical(ofLog)
			ofLogWarning("ofxGraycode") << "Can't add more frames, we've already captured a full set. please clear()";
			return;
		}

		if (!pixels.isAllocated()) {
			ofLogError("ofxGraycode") << "Cannot add this capture as the pixels object is empty";
			return;
		}

		const ofPixels* greyPixels;
		if (pixels.getNumChannels() > 1) {
			ofPixels* downsample = new ofPixels();
			downsample->allocate(pixels.getWidth(), pixels.getHeight(), OF_PIXELS_MONO);
			downsample->set(0, 0);
			const uint8_t* in = pixels.getData();
			uint8_t* out = downsample->getData();
			for (int i = 0; i < pixels.size(); i++, out += (i % pixels.getNumChannels() == 0)) {
				*out += *in++ / pixels.getNumChannels();
			}
			greyPixels = downsample;
		}
		else
			greyPixels = &pixels;

		if (this->payload->isOffline())
			captures.push_back(*greyPixels);
		else
			payload->readPixels(frame, *greyPixels);

		frame++;

		if (frame >= payload->getFrameCount()) {
			calc();
			frame = payload->getFrameCount();
		}

		if (greyPixels != &pixels)
			delete greyPixels;
	}
示例#12
0
//----------------------------------------------------------
void ofTexture::loadData(const ofPixels & pix){
	if(!isAllocated()){
		allocate(pix);
	}else{
		ofSetPixelStoreiAlignment(GL_UNPACK_ALIGNMENT,pix.getBytesStride());
		loadData(pix.getData(), pix.getWidth(), pix.getHeight(), ofGetGlFormat(pix), ofGetGlType(pix));
	}
}
示例#13
0
void ofxImageTS::pixelateInv(ofPixels pixels, int pixelRatio, int X, int Y, int W, int H) {
    ofPixels R,G,B, Rc, Gc, Bc;
    pixels.resize(W,H);
    R = pixels.getChannel(0);
    G = pixels.getChannel(1);
    B = pixels.getChannel(2);
    Rc = R;
    Gc = G;
    Bc = B;
    int c = 0;
    for(int i = R.size()-1; i > 0; i--){
        Rc[c] = R[i];
        Gc[c] = G[i];
        Bc[c] = B[i];
        c++;
    }
    if(pixelRatio > 4 || pixelRatio < 0) {
        ofLogNotice("Pixel Ratio must be between 0 and 5");
    }
    else {
        
        int camWidth = pixels.getWidth();
        int camHeight = pixels.getHeight();
        int boxWidth = pixels.getWidth()/(pow(2,pixelRatio)*10);
        int boxHeight = pixels.getHeight()/(pow(2,pixelRatio)*10);
        
        float tot = boxWidth*boxHeight;
        for (int x = 0; x < camWidth; x += boxWidth) {
            for (int y = 0; y < camHeight; y += boxHeight) {
                float Red = 0, Green = 0, Blue = 0;
                for (int k = 0; k < boxWidth; k++) {
                    for (int l = 0; l < boxHeight; l++) {
                        int index = (x + k) + (y + l) * camWidth;
                        Red += Rc[index];
                        Green += Gc[index];
                        Blue += Bc[index];
                    }
                    ofSetColor(Red/tot,Green/tot,Blue/tot);
                    ofFill();
                    ofDrawRectangle(x+X, y+Y, boxWidth, boxHeight);
                }
            }
        }
    }
}
示例#14
0
//----------------------------------------------------------
void ofTexture::readToPixels(ofPixels & pixels) const {
#ifndef TARGET_OPENGLES
	pixels.allocate(texData.width,texData.height,ofGetImageTypeFromGLType(texData.glInternalFormat));
	ofSetPixelStoreiAlignment(GL_PACK_ALIGNMENT,pixels.getWidth(),pixels.getBytesPerChannel(),pixels.getNumChannels());
	glBindTexture(texData.textureTarget,texData.textureID);
	glGetTexImage(texData.textureTarget,0,ofGetGlFormat(pixels),GL_UNSIGNED_BYTE, pixels.getData());
	glBindTexture(texData.textureTarget,0);
#endif
}
示例#15
0
int ofxCvHaarFinder::findHaarObjects(ofPixels& input, int minWidth, int minHeight){
	ofxCvGrayscaleImage gray;
	gray.allocate(input.getWidth(), input.getHeight());

	if( input.getImageType() == OF_IMAGE_COLOR ){
		ofxCvColorImage color;
		color.allocate(input.getWidth(), input.getHeight());
		color.setFromPixels(input);
		gray = color;
	}else if( input.getImageType() == OF_IMAGE_GRAYSCALE ){
		gray.setFromPixels(input);
	}else{
		ofLog(OF_LOG_ERROR, "ofxCvHaarFinder::findHaarObjects doesn't support OF_IMAGE_RGBA ofImage");
		return 0;
	}

	return findHaarObjects(gray, minWidth, minHeight);
}
示例#16
0
void ofxImageTS::pixelate(ofPixels pixels, int pixelRatio, int X, int Y, int W, int H, int form) {
    if(pixelRatio > 4 || pixelRatio < 0) {
        ofLogNotice("Pixel Ratio must be between 0 and 5");
    }
    else {
        ofPixels R,G,B, copy;
        pixels.resize(W,H);
        copy.allocate(pixels.getWidth(), pixels.getHeight(), OF_PIXELS_RGBA);
        copy = pixels;
        R = copy.getChannel(0);
        G = copy.getChannel(1);
        B = copy.getChannel(2);
        int camWidth = pixels.getWidth();
        int camHeight = pixels.getHeight();
        int boxWidth = pixels.getWidth()/(pow(2,pixelRatio)*10);
        int boxHeight = pixels.getHeight()/(pow(2,pixelRatio)*10);
        
        float tot = boxWidth*boxHeight;
        for (int x = 0; x < camWidth; x += boxWidth) {
            for (int y = 0; y < camHeight; y += boxHeight) {
                float Red = 0, Green = 0, Blue = 0;
                for (int k = 0; k < boxWidth; k++) {
                    for (int l = 0; l < boxHeight; l++) {
                        int index = (x + k) + (y + l) * camWidth;
                        Red += R[index];
                        Green += G[index];
                        Blue += B[index];
                    }
                    ofSetColor(Red/tot,Green/tot,Blue/tot);
                    ofFill();
                    if(form == 1)
                        ofDrawRectangle(x+X, y+Y, boxWidth, boxHeight);
                    if(form == 2)
                        ofDrawBox(x+X, y+Y, boxWidth, boxHeight);
                    if(form == 3)
                        ofDrawCircle(x+X, y+Y, boxWidth, boxHeight);
                    if(form == 4)
                        ofDrawTriangle(x+X, y+Y, X+x+boxHeight, y+Y, x+X, y+Y+boxWidth);
                }
            }
        }
    }
}
示例#17
0
void ofxImageTS::pixSaturation(ofPixels pixels, int pixelRatio, float saturation) {
    if(pixelRatio > 4 || pixelRatio < 0) {
        ofLogNotice("Pixel Ratio must be between 0 and 5");
    }
    else {
        ofPixels R,G,B, copy;
        if(pixels.getWidth() < pixels.getHeight())
            pixels.resize(640,480);
        if(pixels.getWidth() > pixels.getHeight())
            pixels.resize(480,640);
        copy.allocate(pixels.getWidth(), pixels.getHeight(), OF_PIXELS_RGB);
        copy = pixels;
        R = copy.getChannel(0);
        G = copy.getChannel(1);
        B = copy.getChannel(2);
        int camWidth = pixels.getWidth();
        int camHeight = pixels.getHeight();
        int boxWidth = pixels.getWidth()/(pow(2,pixelRatio)*10);
        int boxHeight = pixels.getHeight()/(pow(2,pixelRatio)*10);
        
        float tot = boxWidth*boxHeight;
        for (int x = 0; x < camWidth; x += boxWidth) {
            for (int y = 0; y < camHeight; y += boxHeight) {
                float Red = 0, Green = 0, Blue = 0;
                for (int k = 0; k < boxWidth; k++) {
                    for (int l = 0; l < boxHeight; l++) {
                        int index = (x + k) + (y + l) * camWidth;
                        Red += R[index];
                        Green += G[index];
                        Blue += B[index];
                    }
                    ofColor color;
                    color.set(Red/tot,Green/tot,Blue/tot);
                    color.setSaturation(saturation);
                    ofSetColor(color);
                    ofFill();
                    ofDrawRectangle(x, y, boxWidth, boxHeight);
                }
            }
        }
    }
}
示例#18
0
ofColor testApp::getColorAtPos(ofPixels & pixels, int x, int y){
	
	ofColor pickedColor;
	
	if( x >= 0 && x < pixels.getWidth() && y >= 0 && y < pixels.getHeight() ){
	
		unsigned char * pix = pixels.getPixels();
		int channels = pixels.getNumChannels();
		
		int posInMem = ( y * pixels.getWidth() + x) * channels;
			
		unsigned char r = pix[posInMem]; 
		unsigned char g = pix[posInMem+1]; 
		unsigned char b = pix[posInMem+2]; 
		
		pickedColor.set(r, g, b);
	}
	
	return pickedColor;
}
示例#19
0
SingleImageRecorder::SingleImageRecorder(ofPixels &p)
{
    //SingleImageRecorder::SingleImageRecorder();
    isVisible = true;
    bIsRecording = false;
    brightness = 0;
    
    pixels.allocate(p.getWidth(), p.getHeight(), 1);
    record(p);
    
}
void threadedOpticalFlow::calculateFlow(const ofPixels& _pixels){
    lock();
    
    // realocate if size changed since last update
    if(_pixels.getWidth() != width  &&  _pixels.getHeight() != height){
        width = _pixels.getWidth();
        height = _pixels.getHeight();
        allocateBuffers(width, height);
    }
    
    // deep copy of incoming pixels
    // asumes same values in all channels
    //pixelsInBack.setChannel(0, _pixels.getChannel(0));
    pixelsInBack = _pixels.getChannel(0);
    
    bFlowDirty = true;
    
    condition.signal();
    
    unlock();
}
示例#21
0
ofPixels ofxImageTS::alterColorRGB(ofPixels pixels,float R, float G, float B){
    
    pixels.allocate(pixels.getWidth(), pixels.getHeight(), OF_PIXELS_RGB);
    ofPixels copy;
    copy = pixels;
    for(int i = 0; i < pixels.size()-3; i += 3){
        copy[i] = R * pixels[i];
        copy[i+1] = G * pixels[i+1];
        copy[i+2] = B * pixels[i+2];
    }
    return copy;
}
示例#22
0
ofPixels ofxImageTS::invertRB(ofPixels pixels){
    
    pixels.allocate(pixels.getWidth(), pixels.getHeight(), OF_PIXELS_RGBA);
    ofPixels copy;
    copy = pixels;
    for(int i = 0; i < pixels.size()-3; i += 4){
        copy[i] = pixels[i+2];
        copy[i+1] = pixels[i+1];
        copy[i+2] = pixels[i];
        copy[i+3] = pixels[i+3];
    }
    return copy;
}
void WaterErosion::loadHeightMap(ofPixels& heights) 
{
	width = heights.getWidth();
	height = heights.getHeight();

	//heightMap.allocate(width, height, OF_IMAGE_GRAYSCALE);
	//heightMap.setFromPixels(heights.getPixels(), width, height, OF_IMAGE_GRAYSCALE);

	heightMap = heights;

	flowMap.allocate(width, height, OF_IMAGE_COLOR_ALPHA);

}
示例#24
0
void ofxTurboJpeg::save(ofBuffer &buf, const ofPixels& pix, int jpegQuality)
{
	int pitch = 0, flags = 0, jpegsubsamp = 0;
	unsigned long size = 0;
	
	
	if (pix.getImageType() == OF_IMAGE_COLOR)
	{
		int bpp = 3;
		vector<unsigned char> buffer;
		buffer.resize(pix.getWidth() * pix.getHeight() * bpp);
		
		unsigned char * output = &buffer[0];
		
		tjCompress(handleCompress, (unsigned char*)(pix.getData()), pix.getWidth(), pitch, pix.getHeight(), bpp, output, &size, jpegsubsamp, jpegQuality, flags);
		
		buf.set((const char*)output, size);
	}
	else if (pix.getImageType() == OF_IMAGE_COLOR_ALPHA)
	{
		ofPixels p;
		p.allocate(pix.getWidth(), pix.getHeight(), 3);
		
		const unsigned char *src = pix.getData();
		unsigned char *dst = p.getData();
		
		int num = pix.getWidth() * pix.getHeight();
		for (int i = 0; i < num; i++)
		{
			dst[0] = src[0];
			dst[1] = src[1];
			dst[2] = src[2];
			src += 4;
			dst += 3;
		}
		
		save(buf, p, jpegQuality);
	}
	else if (pix.getImageType() == OF_IMAGE_GRAYSCALE)
	{
		ofPixels p;
		p.allocate(pix.getWidth(), pix.getHeight(), 3);
		
		const unsigned char *src = pix.getData();
		unsigned char *dst = p.getData();
		
		int num = pix.getWidth() * pix.getHeight();
		for (int i = 0; i < num; i++)
		{
			dst[0] = src[0];
			dst[1] = src[0];
			dst[2] = src[0];
			src += 1;
			dst += 3;
		}
		
		save(buf, p, jpegQuality);
	} 
}
示例#25
0
//--------------------------------------------------------------
void ofApp::updateBlobPoints(ofPixels pixels, int step, int min, int max){
    emitterBlob.clear();
    int w = pixels.getWidth();
    int h = pixels.getHeight();
    int channels = pixels.getNumChannels();
    for(int x=0; x<w; x+=step){
        for(int y=0; y<h; y+=step){
            int i = (x + y * w) * channels;
            if(pixels[i] > min  && pixels[i] < max){
                emitterBlob.setPoint(ofPoint(x,y) * transformWarpToProjector);
            }
        }
    }
}
示例#26
0
	//----------
	void Message::setData(const ofPixels & data) {
		const auto headerSize = sizeof(Header::Pixels);
		const auto bodySize = data.size(); // inner payload

		this->headerAndData.resize(headerSize + bodySize);

		auto & header = this->getHeader<Header::Pixels>(true);
		header.width = data.getWidth();
		header.height = data.getHeight();
		header.pixelFormat = data.getPixelFormat();

		auto body = this->getBodyData();
		memcpy(body, data.getData(), bodySize);
	}
bool Chessboard::findCorners(ofPixels &image, vector<ofVec2f> &points) const {
	int subPixSearch = image.getWidth() / squaresX / 10.0f;
	if (subPixSearch % 2 == subPixSearch)
		subPixSearch++; //ensure odd numbers
	
    int chessFlags = CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FAST_CHECK;
    bool found;
	
	Mat img = toCv(image);
    
    found = findChessboardCorners(img, cv::Size(squaresX-1, squaresY-1), *(vector<Point2f>*)&points, chessFlags);
    
    return found;
}
示例#28
0
void removeIslands(ofPixels& img) {
	int w = img.getWidth(), h = img.getHeight();
	int ia1=-w-1,ia2=-w-0,ia3=-w+1,ib1=-0-1,ib3=-0+1,ic1=+w-1,ic2=+w-0,ic3=+w+1;
	unsigned char* p = img.getPixels();
	for(int y = 1; y + 1 < h; y++) {
		for(int x = 1; x + 1 < w; x++) {
			int i = y * w + x;
			if(p[i]) {
				if(!p[i+ia1]&&!p[i+ia2]&&!p[i+ia3]&&!p[i+ib1]&&!p[i+ib3]&&!p[i+ic1]&&!p[i+ic2]&&!p[i+ic3]) {
					p[i] = 0;
				}
			}
		}
	}
}
//------------------------------------------------------------------------------
void BaseWebSocketSessionManager::broadcast(ofPixels& pixels)
{
    ofScopedLock lock(_mutex);
    WebSocketConnectionsIter iter = _connections.begin();

    int numChannels = pixels.getNumChannels();
    int width       = pixels.getWidth();
    int height      = pixels.getHeight();

    while(iter != _connections.end())
    {
        ofPixels pixels;
        //sendFrame(*iter,frame);
        ++iter;
    }
}
示例#30
0
bool toDLib(const ofPixels& inPix, array2d<rgb_pixel>& outPix){
    
    int width = inPix.getWidth();
    int height = inPix.getHeight();
    outPix.set_size( height, width );
    int chans = inPix.getNumChannels();
    const unsigned char* data = inPix.getData();
    for ( unsigned n = 0; n < height;n++ )
    {
        const unsigned char* v =  &data[n * width *  chans];
        for ( unsigned m = 0; m < width;m++ )
        {
            if ( chans==1 )
            {
                unsigned char p = v[m];
                assign_pixel( outPix[n][m], p );
            }
            else{
                rgb_pixel p;
                p.red = v[m*3];
                p.green = v[m*3+1];
                p.blue = v[m*3+2];
                assign_pixel( outPix[n][m], p );
            }
        }
    }
//    if(inPix.getNumChannels() == 3){
//        int h = inPix.getHeight();
//        int w = inPix.getWidth();
//        outPix.clear();
//        outPix.set_size(h,w);
//        for (int i = 0; i < h; i++) {
//            for (int j = 0; j < w; j++) {
//                
//                outPix[i][j].red = inPix.getColor(j, i).r; //inPix[i*w + j];
//                outPix[i][j].green = inPix.getColor(j, i).g; //inPix[i*w + j + 1];
//                outPix[i][j].blue = inPix.getColor(j, i).b; //inPix[i*w + j + 2];
//            }
//        }
//        return true;
//    }else{
//        return  false;
//    }
    return true;
}