Example #1
0
File: hw2.cpp Project: j0x7c4/cvhw
//a binary image (threshold at 128)
void CVHW::binary(cv::Mat& t_image, int threshold)
{
	int m = t_image.rows;
	int n = t_image.cols;
	//int a,b;
	//a=b=0;
	printf("binary\n");
	printf("Threshold is %d\n",threshold);
	for ( int i = 0 ; i<m ; i++ )
	{
		for ( int j = 0 ; j<n ; j++ )
		{
			//printf("%d ",get_pix(i,j));
			if ( get_pix(t_image,i,j)>=threshold )
			{
				//a++;
				set_pix(t_image,i,j,255);
			}
			else
			{
				//b++;
				set_pix(t_image,i,j,0);
			}
		}
	}
	//printf("%d,%d\n",a,b);
}
Example #2
0
File: hw2.cpp Project: j0x7c4/cvhw
void CVHW::mark_centroid ( cv::Mat& t_image, int x, int y ,int r )
{
	int mv[4][2] = { -1,0,0,1,1,0,0,-1};
	for ( int i = 0 ; i<4 ; i++ )
	{
		set_pix(t_image,x,y,GRAY);
		for ( int j = 1 ; j<r ; j++ )
		{
			set_pix(t_image,x+mv[i][0]*j,y+mv[i][1]*j,GRAY);
		}
	}
}
Example #3
0
File: viewer.c Project: jafp/eyebot
static void draw_center_point2(int x, int y, int rr, int gg, int bb)
{
    int r, c, o, o1;

    // Skip drawing the point if is so close to the border
    // that we cannot draw a 10x10 dot
    if (x > (UP_W - 5) || x < 5 || y > (UP_H - 5) || y < 5)
    {   
        return;
    }

    // Draw the blue center point
    for (r = y - 5; r < y + 5; r++)
    {
        //o = r * WIDTH * 4;
        for (c = x - 5; c < x + 5; c++)
        {   
            // Calculate pixel offet
            o = r * UP_W + c;
            assert(o < UP_S);

            o1 = o * CHANNELS;
            set_pix(o1, rr, gg, bb);
        }
    }
}
Example #4
0
void    
ProxySurface::apply_xform()
{
   if(!_patch)
      return;
   // apply the transform to the vertices of the proxy mesh
   assert(_proxy_mesh);
 
   PIXEL o = _patch->get_old_sample_center();
   PIXEL n = _patch->get_sample_center();
   VEXEL z = _patch->get_z();


   CBvert_list&  verts = _proxy_mesh->verts();    // vertices of the proxy mesh
   PIXEL_list   pixels = get_pixels(verts, this); // their old pixel locations

   // compute and apply the transform to each vertex:
   for (int i=0; i<verts.num(); i++) {
      set_pix(verts[i], this, n + cmult(pixels[i] - o, z));
   }

   //cache _uv_orig, _uv_u_pt, _uv_v_pt so that we can grow new quads
   _o = n + cmult(_o - o, z);
   _u_o = n + cmult(_u_o - o, z);
   _v_o = n + cmult(_v_o - o, z);

   // take care of bizness:
   _proxy_mesh->changed(); //BMESH::VERT_POSITIONS_CHANGED
}
Example #5
0
File: hw2.cpp Project: j0x7c4/cvhw
void CVHW::draw_connected_components ( cv::Mat& t_image, BOUNDING_BOX&  box )
{
	for ( int i = box.top_left_x ; i<=box.bottom_right_x ; i++ ) // draw |
	{
		set_pix(t_image,i,box.top_left_y,GRAY);
		set_pix(t_image,i,box.bottom_right_y,GRAY);
	}

	for ( int i = box.top_left_y ; i<= box.bottom_right_y ; i++ )
	{
		set_pix(t_image,box.top_left_x,i,GRAY);
		set_pix(t_image,box.bottom_right_x,i,GRAY);
	}

	mark_centroid(t_image,box.centroid_x,box.centroid_y,4);
}
Example #6
0
File: viewer.c Project: jafp/eyebot
static void upscale_image()
{
    int x, y, o, no;
    unsigned char p;

    for (y = 0; y < HEIGHT; y++)
    {
        for (x = 0; x < WIDTH; x++)
        {
            o = y * WIDTH + x;
            p = read_buffer[o];

            no = 2*y*UP_W + x*2;

            set_pix(no, p, p, p);
            set_pix(no+1, p, p, p);
            set_pix(no+UP_W, p, p, p);
            set_pix(no+1+UP_W, p, p, p);
        }
    }
}
Example #7
0
File: viewer.c Project: jafp/eyebot
static void draw_center_lines2()
{
    int r, o, m;

    // Draw the red center line vertical
    m = UP_W / 2;
    for (r = 0; r < UP_H; r++)
    {
        o = (r * UP_W + m) * CHANNELS;
        //set_pixel_value_at_off(get_pixel_offset(o), 255, 0, 0);
        set_pix(o, 255, 0, 0);
    }

    // Draw the red center line horizontal
    m = UP_H / 2;
    for (r = 0; r < UP_W; r++)
    {
        o = (m * UP_W + r) * CHANNELS;
        set_pix(o, 255, 0, 0);
        //set_pixel_value_at_off(get_pixel_offset(o), 255, 0, 0);

    }
}
Example #8
0
static void set_bg(uint8_t *pixel){
	set_pix(pixel,framebuffer->bg_color);
}