Exemplo n.º 1
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);
    }
    
}
Exemplo n.º 2
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);
    } 
}
Exemplo n.º 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());
	}
}
Exemplo n.º 4
0
void ofPixels::operator=(const ofPixels & mom){
	if(mom.isAllocated()){
		allocate(mom.getWidth(),mom.getHeight(),mom.getImageType());
		memcpy(pixels,mom.getPixels(),mom.getWidth()*mom.getHeight()*mom.getBytesPerPixel());
	}
}