void CEnemyObject::groundCollision()
{
	if((getPositionY() > 600.0F - getImageHeight()))
	{
		setPositionY(600.0F - getImageHeight());
		setVelocityY(0);
	}
}
示例#2
0
GC3Denum WebGLFramebuffer::checkStatus() const
{
    unsigned int count = 0;
    GC3Dsizei width = 0, height = 0;
    if (isDepthAttached()) {
        if (!isAttachmentComplete(m_depthAttachment.get(), GraphicsContext3D::DEPTH_ATTACHMENT))
            return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
        width = getImageWidth(m_depthAttachment.get());
        height = getImageHeight(m_depthAttachment.get());
        count++;
    }
    if (isStencilAttached()) {
        if (!isAttachmentComplete(m_stencilAttachment.get(), GraphicsContext3D::STENCIL_ATTACHMENT))
            return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
        if (!count) {
            width = getImageWidth(m_stencilAttachment.get());
            height = getImageHeight(m_stencilAttachment.get());
        } else {
            if (width != getImageWidth(m_stencilAttachment.get()) || height != getImageHeight(m_stencilAttachment.get()))
                return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
        }
        count++;
    }
    if (isDepthStencilAttached()) {
        if (!isAttachmentComplete(m_depthStencilAttachment.get(), GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT))
            return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
        if (!isValidRenderbuffer(m_depthStencilAttachment.get()))
            return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED;
        if (!count) {
            width = getImageWidth(m_depthStencilAttachment.get());
            height = getImageHeight(m_depthStencilAttachment.get());
        } else {
            if (width != getImageWidth(m_depthStencilAttachment.get()) || height != getImageHeight(m_depthStencilAttachment.get()))
                return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
        }
        count++;
    }
    // WebGL specific: no conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments.
    if (count > 1)
        return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED;
    if (isColorAttached()) {
        // FIXME: if color buffer is texture, is ALPHA, LUMINANCE or LUMINANCE_ALPHA valid?
        if (!getColorBufferFormat())
            return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
        if (!count) {
            if (!getColorBufferWidth() || !getColorBufferHeight())
                return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
        } else {
            if (width != getColorBufferWidth() || height != getColorBufferHeight())
                return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
        }
    } else {
        if (!count)
            return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
    }
    return GraphicsContext3D::FRAMEBUFFER_COMPLETE;
}
void FillColorMenuToolButton::drawImageSurface(const Cairo::RefPtr<Cairo::Context> context)
{
	Gdk::Cairo::set_source_pixbuf (context, pixbuf_, 3.0, 0.0);
    context->paint();
	
	drawColorRectangle (context, 0.5, getImageHeight() - 4.5, getImageWidth() - 0.5, 5 - 0.5);
}
std::vector<Eigen::Vector3f> ImageReader::toVector(){
    std::vector<Eigen::Vector3f> output;
    for (int i = 0; i < getImageHeight(); i++) {
        for (int j = 0; j < getImageWidth(); j++) {
            QColor pixelColor = QColor(pixelAt(i,j));
            Eigen::Vector3f color = Eigen::Vector3f(float(pixelColor.red()), float(pixelColor.green()), float(pixelColor.blue()));
            output.push_back(color);
        }
    }
    return output;
}
示例#5
0
void draw(void *userData)
{
	DemoData *d = (DemoData *) userData;
	char buf[256];
	int x, y;
	
	/* Exit on key press */
	if (getKey())
		exitPolo();
	
	/* Clear screen with right mouse button */
	if (isMouseButtonPressed(1))
		clearScreen();
	
	/* Paint with left mouse button */
	if (isMouseButtonPressed(0))
	{
		if ((getMouseX() < 128) && (getMouseY() < 128))
			setDrawTint(getColorFromHSVA(getMouseX() / 128,
			                             getMouseY() / 128,
			                             1,
			                             BRUSH_ALPHA));
		else
			drawImage(getMouseX() - getImageWidth(d->brush) / 2,
			          getMouseY() - getImageHeight(d->brush) / 2,
			          d->brush);
	}
	
	/* Draw left bar */
	setPenColor(POLO_STEEL);
	setFillGradient(POLO_SILVER, POLO_TUNGSTEN);
	drawRect(-1, -1, TOOLBAR_WIDTH, getScreenHeight() + 2);
	
	/* Draw frames per second and time display */
	setPenColor(POLO_BLACK);
	sprintf(buf, "FPS: %.3f", d->frame / (getTime() + 0.001));
	drawText((TOOLBAR_WIDTH - getTextDrawWidth(buf)) / 2,
	         getScreenHeight() - getTextDrawHeight(buf) - 10,
	         buf);
	
	/* Increment frame number */
	d->frame++;
	
	/* Paint color palette */
	for (x = 0; x < 128; x++)
		for (y = 0; y < 128; y++)
		{
			setPenColor(getColorFromHSV(x / 128.0,
			                            y / 128.0,
			                            1.0));
			drawPoint(x, y);
		}
}
void ColorMenuToolButtonBase::drawColorRectangle(const Cairo::RefPtr< Cairo::Context > context, double x, double y, double w, double h)
{
    if (has_color_)
    {
        context->rectangle (0, getImageHeight() - 5, getImageWidth(), 5);
#ifdef GTKMM_3
        selected_color_.useInCairo (context);
#else
        selected_color_.useInCairoRev (context);
#endif
        context->fill();
    }
    else
    {
        context->set_line_width (1.0);
        context->rectangle (0.5, getImageHeight() - 4.5, getImageWidth() - 0.5, 5 - 0.5);

        context->set_source_rgb (0, 0, 0);
        context->stroke();
    }
}
void ImageReader::findMinAndMax()
{
    int min = 10000000000;
    int max = -1;

    for (int i = 0; i < getImageHeight(); i++) {
        for (int j = 0; j < getImageWidth(); j++) {
            if (QColor(pixelAt(i,j)).red() > 150) {
                if (j > max) {
                    max = j;
                }
                if (j < min) {
                    min = j;
                }
            }
        }
    }

    assert(max > min);
    m_xMax = max;
    m_xMin = min;
}
示例#8
0
void Layout::update(const AlbumItemContainer &items, const Size2i &clientSize, ImageCache &imageCache)
{
	updateCellLayout();

	lines_.clear();
	itemCount_ = items.size();
	columns_ = std::max(1, (clientSize.w + columnSpace_) / cellStepX_);

	typedef AlbumItemContainer::const_iterator ItemIt;

	class LineDivider
	{
		const unsigned int columns_;
		const ItemIt beg_;
		const ItemIt end_;
		ItemIt curr_;
	public:
		LineDivider(unsigned int columns, const ItemIt &beg, const ItemIt &end)
			: columns_(columns), beg_(beg), end_(end), curr_(beg) {}

		bool isTerminated() const { return curr_ == end_;}
		const ItemIt &getCurrent() const { return curr_;}
		ItemIt getLineEnd()
		{
			unsigned int count = 0;
			for(;;){
				if(curr_ == end_){
					return curr_;
				}
				if((*curr_)->isLineBreak()){
					const ItemIt lineEnd = curr_;
					++curr_;
					return lineEnd;
				}
				if(count++ >= columns_){
					return curr_;
				}
				++curr_;
			}
		}
	};

	LineDivider lineDivider(columns_, items.begin(), items.end());

	int lineTop = 0;
	while(!lineDivider.isTerminated()){
		const ItemIt lineBeg = lineDivider.getCurrent();
		const ItemIt lineEnd = lineDivider.getLineEnd();

		// 画像の高さがAUTOの場合、行内の最大の画像の高さを求める。
		if(isImageHeightAuto()){
			const int maxImageHeight = std::accumulate(lineBeg, lineEnd, 0, [&](int maxImageHeight, const AlbumItemPtr &item) -> int {
				switch(item->getType()){
				case AlbumItem::TYPE_LINE_BREAK:
					break;
				case AlbumItem::TYPE_PICTURE:
					if(const AlbumPicture *pic = dynamic_cast<const AlbumPicture *>(item.get())){
						if(const ImagePtr im = imageCache.getImage(pic->getFilePath(), Size2i(getImageWidth(), getImageHeight()))){
							return std::max(maxImageHeight, im->getHeight());
						}
					}
					break;
				}
				return maxImageHeight;
			});
			lines_.insert(LineContainer::value_type(lineBeg - items.begin(), LineInfo(lineTop, maxImageHeight)));
			lineTop += maxImageHeight + nameHeight_ + lineSpace_;
		}
		else{
			lines_.insert(LineContainer::value_type(lineBeg - items.begin(), LineInfo(lineTop, imageHeight_)));
			lineTop += cellStepY_;
		}

	}

	pageSize_.set(
		columns_ * cellStepX_ - columnSpace_,
		lineTop ? lineTop - lineSpace_ : 0);
}
unsigned int ImageSplit(unsigned char *data,int width, int height){
    int i,j,k;
	int w,h;
	int left,right;
	int pixel_num = 0;
	int top_height,bot_height;
	int new_height = getImageHeight(data,width,height,&top_height,&bot_height);
	int l_width = ((width*3+3)>>2)<<2;
	
	float calc_out[ANN_OUTPUT_NUM];
	int   calc_iout[ANN_OUTPUT_NUM];
	
	unsigned char recogArr[13]={0};
	int index = 0;
	left = right = 0;
	
	while(1){
		if (left >= width){
		    break;
		}
		
		while(left < width){
		    pixel_num = 0;
		    for (i=0; i<height; i++){/*scan from bottom to top*/
                k = i*l_width + left*3;
				if (data[k] == 0 && data[k+1] == 0 && data[k+2] == 0){
				    pixel_num ++;
				}
			}
			
			if (pixel_num <= 1){
			    left ++;
			}
			else{
			    break;
			}
		}
		
		right = left + 1;
		
		if (right >= width){
		    break;
		}
		
		while(right < width){
		    pixel_num = 0;
		    for (i=0;i<height; i++){
                k = i*l_width + right*3;
				if (data[k] == 0 && data[k+1] == 0 && data[k+2] == 0){
				    pixel_num ++;
				}
			}
			
			if (pixel_num > 1){
			    right++;
			}
			else{
			    break;
			}
		}
		
		if (right >= width){
		    break;
		}
		
		if ((right-left) <= 2){
		    left = right + 1;
			continue;
		}
		
		if (IsHorizonLine(data,left,right,width,height) == 1){ /* symbol "-" ? */
		    left = right + 1;
		    continue;
		}
		
		set_verticalbar_blue(data,width,height,left,right-1);
#if 1		
		int recogNum = 0;
		if ((right-left) <= MAX_CHAR_WIDTH){
		    int top_pos = 0;
			int bot_pos = 0;
//			int left_pos = 0;
//			int right_pos = 0;
			getSlicedHeight(data,left,right,width,height,&top_pos,&bot_pos);
//			getSlicedWidth(data,left,right,width,height,&left_pos,&right_pos);
//		    unsigned char *one_ch = new unsigned char[(right-left)*(top_height-bot_height+1)];
            unsigned char *one_ch = new unsigned char[(right-left + 1)*(top_pos-bot_pos+1)];
			if (one_ch == NULL){
			    printf("(%d) allocate memory failed\n",__LINE__);
			}
			copy_char(data,one_ch,left,right,top_pos,bot_pos,width);
			unsigned char *norm_data = new unsigned char[NORM_WIDTH*NORM_HEIGHT];
			if (norm_data == NULL){
			    printf("(%d) allocate memory failed\n",__LINE__);
			}
			
//			norm_data = ImageNorm(one_ch,right-left,top_height-bot_height+1);
            norm_data = ImageNorm(one_ch,norm_data,right - left+1, top_pos-bot_pos+1);
//			ImageThinning(norm_data,NORM_WIDTH,NORM_HEIGHT);
			float *feature_vector = new float[MAX_FEATURE_LEN];
			if (feature_vector == NULL){
			    printf("(%d) allocate memory failed\n",__LINE__);
			}
            memset(feature_vector,0,MAX_FEATURE_LEN);

            getfeatureVector(norm_data,feature_vector,NORM_WIDTH,NORM_HEIGHT);
#if 1
			PRINT_NORM(norm_data,NORM_WIDTH,NORM_HEIGHT);
			PRINT_FEATURE(feature_vector,MAX_FEATURE_LEN);
#endif
            
            recogDigital(feature_vector,&calc_out[0]);
			
			printf("%f %f %f %f\n",calc_out[0],calc_out[1],calc_out[2],calc_out[3]);
			
			for (i=0; i<4; i++){
			    if (fabs(calc_out[i]) > 0.5){
				    calc_iout[i] = 1;
					
				}
				else{
				    calc_iout[i] = 0;
				}
			}
			
		    printf("%d  %d %d %d\n",calc_iout[0],calc_iout[1],calc_iout[2],calc_iout[3]);
			recogNum = (calc_iout[0]<<3)+(calc_iout[1]<<2) + (calc_iout[2]<<1) + calc_iout[3];
			
		    if (recogNum > 9){
		         printf("recognized failure(recogNum = %d)\n",recogNum);
			     recogArr[index]='X';
				 index++;
//			     exit(1);
		    }
		    else{
		        printf("%d\n",recogNum);
				recogArr[index]=recogNum;
				index++;
		    }

#if 1			
			set_verticalbar_blue(data,width,height,left,right-1);
#endif
            delete[] one_ch;
            delete[] norm_data;
			delete[] feature_vector;
		}
		else{
#if 1
		    int new_left  = left;
		    int new_right = new_left + MIN_WINDOW_LEN;
			int loop = 0;
			while(new_right < right){
			    int recog_sliced = 0;
				int temp_left = 0;
				int temp_right = 0;
//				printf("new_left =%d, new_right=%d,left=%d,right=%d\n",new_left,new_right,left,right);
				
				if ((new_right - new_left) == MIN_WINDOW_LEN){
				    printf("new_left=%d,new_right=%d,left=%d,right=%d\n",new_left,new_right,left,right);
					if (IsHorizonLine(data,new_left,new_right,width,height) == 1){
					    new_left = new_right + 1;
						new_right = new_left + MIN_WINDOW_LEN;
						continue;
					}
					
				    recog_sliced = recog_one_sliced(data,new_left,new_right,top_height, bot_height, width,height);
					
					if (recog_sliced != 1){
					    temp_left = new_left -1;
						temp_right = new_right -1;
						printf("new_left=%d,new_right=%d,left=%d,right=%d\n",temp_left,temp_right,left,right);
						
						if (IsHorizonLine(data,temp_left,temp_right,width,height) == 1){
						    new_left = temp_right + 1;
							new_right = new_left + MIN_WINDOW_LEN;
							continue;
						}
						
						recog_sliced = recog_one_sliced(data,temp_left,temp_right,top_height,bot_height,width,height);
						if (recog_sliced != 1){
						    temp_left = new_left + 1;
							temp_right = new_right + 1;
							if (temp_right >= right){
							    new_right = right;/*do nothing, end this while loop*/
							}
							else{
							    printf("new_left=%d,new_right=%d,left=%d,right=%d\n",temp_left,temp_right,left,right);
								if (IsHorizonLine(data,temp_left,temp_right,width,height) == 1){
								    new_left = temp_right + 1;
									new_right = new_left + MIN_WINDOW_LEN;
									continue;
								}
							    recog_sliced = recog_one_sliced(data,temp_left,temp_right,top_height,bot_height,width,height);
								if (recog_sliced != 1){
								    //new_right = new_left + MAX_WINDOW_LEN;
									
									//if (new_right >= right){
									//    new_right = right -1;
									//}
									new_right = new_left + MIN_WINDOW_LEN + 1;
									
								}
								else{
								    printf("%d\n",recog_sliced);
									recogArr[index]=recog_sliced;
									index++;
									//new_left = new_right + 1;
									new_left = temp_right + 1;
									new_right = new_left + MIN_WINDOW_LEN ;
									/*go to next loop*/
								}
							}
						}
						else{
						    printf("%d\n",recog_sliced);
							recogArr[index] = recog_sliced;
							index++;
							new_left = temp_right + 1;
							new_right = new_left + MIN_WINDOW_LEN;
						}
					}
					else{
					    printf("%d\n",recog_sliced);
						recogArr[index] = recog_sliced;
						index++;
					    new_left = new_right + 1;
						new_right = new_left + MIN_WINDOW_LEN;
						/*if new_right > right, end this while loop*/
					}
				}
				
				if ((new_right - new_left) == (MIN_WINDOW_LEN + 1)){
				    printf("new_left=%d,new_right=%d,left=%d,right=%d\n",new_left,new_right,left,right);
					if (IsHorizonLine(data,new_left,new_right,width,height) == 1){
					    new_left = new_right + 1;
						new_right = new_left + MIN_WINDOW_LEN;
						continue;
					}
					recog_sliced = recog_one_sliced(data,new_left,new_right,top_height, bot_height, width,height);
					if (recog_sliced != 1){
					    temp_left = new_left - 1;
						temp_right = new_right - 1;
						printf("new_left=%d,new_right=%d,left=%d,right=%d\n",temp_left,temp_right,left,right);
						if (IsHorizonLine(data,temp_left,temp_right,width, height) == 1){
						    new_left = new_right + 1;
							new_right = new_left + MIN_WINDOW_LEN;
							continue;
						}
						
						recog_sliced = recog_one_sliced(data,temp_left,temp_right,top_height,bot_height,width,height);
						if (recog_sliced != 1){
						    temp_left = new_left + 1;
							temp_right = new_right + 1;
							 printf("new_left=%d,new_right=%d,left=%d,right=%d\n",temp_left,temp_right,left,right);
							if (temp_right >= right){
							    new_right = right; /*do nothing, just end this loop*/
							}
							else{
							    if (IsHorizonLine(data,temp_left,temp_right,width,height) == 1){
								    new_left = temp_right + 1;
									new_right = new_left + MIN_WINDOW_LEN;
									continue;
								}
								
								recog_sliced = recog_one_sliced(data,temp_left,temp_right,top_height,bot_height,width,height);
								if (recog_sliced != 1){
								    new_right = new_left + MAX_WINDOW_LEN;
									if (new_right >= right){
									    new_right = right - 1;
									}
								}
								else{
								    printf("%d\n",recog_sliced);
									recogArr[index] = recog_sliced;
									index++;
									
									new_left = temp_right + 1;
									new_right = new_left + MIN_WINDOW_LEN;
								}
							}
							
						}
						else{
						    printf("%d\n",recog_sliced);
							recogArr[index] = recog_sliced;
							index ++;
							
							new_left = temp_right + 1;
							new_right = new_left + MIN_WINDOW_LEN; /*if new_right > right,just end this loop*/
						}
					}
					else{
					    printf("%d\n",recog_sliced);
						recogArr[index] = recog_sliced;
						index++;
						
					    new_left = new_right + 1;
						new_right = new_left + MIN_WINDOW_LEN;
					}
				}
				
				if ((new_right - new_left) > (MIN_WINDOW_LEN+1) && (new_right - new_left) <= MAX_WINDOW_LEN){
				    printf("new_left=%d,new_right=%d,left=%d,right=%d\n",new_left,new_right,left,right);
				    recog_sliced = recog_one_sliced(data,new_left,new_right,top_height,bot_height,width,height);
					if ((recog_sliced == 1 || recog_sliced < 0 || recog_sliced >= 10) /*|| (index == 1 && (recog_sliced != 3 || recog_sliced != 5 || recog_sliced != 8))*/){
					    /*failed*/
						temp_left = new_left -1;
						temp_right = new_right -1;
						/*recognize again*/
						printf("new_left=%d,new_right=%d,left=%d,right=%d\n",temp_left,temp_right,left,right);
						recog_sliced = recog_one_sliced(data,temp_left,temp_right,top_height,bot_height,width,height);
						if ((recog_sliced < 0 || recog_sliced >= 10)/* ||(index == 1 && (recog_sliced != 3 || recog_sliced != 5 || recog_sliced != 8))*/){
						    /*failed again*/
							temp_left = new_left + 1;
							temp_right = new_right + 1;
							if (temp_right >= right){
							    temp_right = right -1;
							}
							
							/*the last try*/
							printf("new_left=%d,new_right=%d,left=%d,right=%d\n",temp_left,temp_right,left,right);
							recog_sliced = recog_one_sliced(data,temp_left,temp_right,top_height,bot_height,width,height);
							if (( recog_sliced < 0 || recog_sliced >= 10) /*||(index == 1 && (recog_sliced != 3 || recog_sliced != 5 || recog_sliced != 8))*/){
							    /*still failed*/
								/*keep new_left unchange*/
								new_right = new_left + (MAX_WINDOW_LEN + 1);
								if (new_right >= right){
								    new_right ++;/*here just end this loop*/
								}
							}
							else{
							    /*success*/
							    printf("%d\n",recog_sliced);
								recogArr[index]=recog_sliced;
								index++;
								new_left = temp_right + 1;
								new_right = new_left + MIN_WINDOW_LEN;
								/*go to next loop*/
							}
							
							
						}
						else{
						    /*success*/
							printf("%d\n",recog_sliced);
							recogArr[index] = recog_sliced;
							index++;
							new_left = temp_right + 1;
							new_right = new_left + MIN_WINDOW_LEN;
							/*go to next loop*/
						}
					}
					else{
					    printf("%d\n",recog_sliced);
						recogArr[index]=recog_sliced;
						index++;
						new_left = new_right + 1;
						new_right = new_left + MIN_WINDOW_LEN;
						/*go to next while loop. if new_right > right, just stop this while loop*/
					}
				}
				
				if ((new_right - new_left) == (MAX_WINDOW_LEN + 1)){
				    printf("new_left=%d,new_right=%d,left=%d,right=%d\n",new_left,new_right,left,right);
				    recog_sliced = recog_one_sliced(data,new_left,new_right,top_height,bot_height,width,height);
					if ((recog_sliced < 0 || recog_sliced >= 10) /*|| (index == 1 && (recog_sliced != 3 || recog_sliced != 5 || recog_sliced != 8))*/){
					    /*failed*/
						temp_left = new_left - 1;
						temp_right = new_right -1;
						/*recognize again*/
						printf("new_left=%d,new_right=%d,left=%d,right=%d\n",temp_left,temp_right,left,right);
						recog_sliced = recog_one_sliced(data,temp_left,temp_right,top_height,bot_height,width,height);
						if ((recog_sliced < 0 || recog_sliced >= 10) /*|| (index == 1 && (recog_sliced != 3 || recog_sliced != 5 || recog_sliced != 8))*/){
						    /*failed again*/
							temp_left = new_left + 1;
							temp_right = new_right + 1;
							if (temp_right >= right){
							    temp_right = right -1;
							}
							
							/*last recog try*/
							printf("new_left=%d,new_right=%d,left=%d,right=%d\n",temp_left,temp_right,left,right);
							recog_sliced = recog_one_sliced(data,temp_left,temp_right,top_height,bot_height,width,height);
							if ((recog_sliced == 1 || recog_sliced < 0 || recog_sliced >= 10) /*|| (index == 1 && (recog_sliced != 3 || recog_sliced != 5 || recog_sliced != 8))*/){
							    /*totally failed*/
								new_left = new_right + 1;
								new_right = new_left + MIN_WINDOW_LEN;
								/*do not do it again*/
								printf("%d:recog given up\n",__LINE__);
								recogArr[index]='X';
								index++;
							}
							else{
							    printf("%d\n",recog_sliced);
								recogArr[index]=recog_sliced;
								index++;
								new_left = temp_right + 1;
								new_right = new_left + MIN_WINDOW_LEN;
								/*go to next loop*/
							}
							
						}
						else{
						    printf("%d\n",recog_sliced);
							recogArr[index]=recog_sliced;
							index++;
							new_left = temp_right + 1;
							new_right = new_left + MIN_WINDOW_LEN;
						}
					}
					else{
					    /*success*/
						printf("%d\n",recog_sliced);
						recogArr[index]=recog_sliced;
						index++;
						new_left = new_right + 1;
						new_right = new_left + MIN_WINDOW_LEN;
						/*if new_right >= right ,just end this loop*/
					}
				}
			}  
#endif 			
		}
#endif		
		left = right;
		
	}
	
	for (i=0; i<index; i++){
	    if (recogArr[i] !='X'){
		    printf("%d",recogArr[i]);
		}
		else{
		    printf("%c",recogArr[i]);
		}
	}
	printf("\n");
}
示例#10
0
Ray Screen::getRay(unsigned int image_width, unsigned int x, unsigned int y) const {
	return getRay( double(x) / double(image_width), double(y) / double(getImageHeight(image_width)));
}
示例#11
0
文件: RF.c 项目: tonemapping/matlab2C
int main(int argc, char** argv) {

    float** testRedChannel = generateImageArray("red.txt");
    float** testGreenChannel = generateImageArray("green.txt");
    float** testBlueChannel = generateImageArray("blue.txt");

    int h = getImageWidth("red.txt");
    int w = getImageHeight("red.txt");
    printf("%i rows x %i columns\n", h, w);

    ///////////////////////////////////////////////////////////
    //////Compute the l1-norm distance of neighbor pixels./////
    ///////////////////////////////////////////////////////////

    float** dIcdxRed = diffH(testRedChannel, h,w);
    float** dIcdxGreen = diffH(testGreenChannel, h,w);
    float** dIcdxBlue = diffH(testBlueChannel, h,w);

    float** dIcdx = addChannels(dIcdxRed, dIcdxGreen, dIcdxBlue, h,w);
    destroyArray(dIcdxRed);
    destroyArray(dIcdxGreen);
    destroyArray(dIcdxBlue);

    float** dIcdyRed = diffV(testRedChannel, h,w);
    float** dIcdyGreen = diffV(testGreenChannel, h,w);
    float** dIcdyBlue = diffV(testBlueChannel, h,w);

    float** dIcdy = addChannels(dIcdyRed, dIcdyGreen, dIcdyBlue, h,w);
    destroyArray(dIcdyRed);
    destroyArray(dIcdyGreen);
    destroyArray(dIcdyBlue);

    ///////////////////////////////////////////////////////////
    ///////Compute the derivatives of the horizontal///////////
    ///////and vertical domain transforms./////////////////////
    ///////////////////////////////////////////////////////////

    float factor = sigma_s / sigma_r;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            dIcdx[i][j] = 1 + factor * dIcdx[i][j];
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            dIcdy[i][j] = 1 + factor * dIcdy[i][j];
        }
    }
    ///The vertical pass is performed using a transposed image.
    float** dHdyT = transpose(dIcdy, h, w);
    destroyArray(dIcdy);

    ///////////////////////////////////////////////////////////
    ///////////////////Perform the filtering.//////////////////
    ///////////////////////////////////////////////////////////

    filtering(testRedChannel, dIcdx, dHdyT, h, w, 10);
    filtering(testGreenChannel, dIcdx, dHdyT, h, w, 10);
    filtering(testBlueChannel, dIcdx, dHdyT, h, w, 10);

    ///////////////////////////////////////////////////////////
    ///////////////////GENERATE OUTPUT IMAGE///////////////////
    ///////////////////////////////////////////////////////////

    generateImageFile(testRedChannel, "outred.txt", h, w);
    generateImageFile(testGreenChannel, "outgreen.txt", h, w);
    generateImageFile(testBlueChannel, "outblue.txt", h, w);

    ///////////////////////////////////////////////////////////
    ///////////////////////FREE MEMORY/////////////////////////
    ///////////////////////////////////////////////////////////

    destroyArray(dIcdx);
    destroyArray(dHdyT);
    destroyArray(testRedChannel);
    destroyArray(testGreenChannel);
    destroyArray(testBlueChannel);
    return 0;
}