示例#1
0
 /// <summary>
 /// show the histogram in an image object
 /// </summary>
 /// <param name="img"></param>
 public void Show(classimage img)
 {
     int prev_x = 0, prev_y = 0;
     img.clear();
     for (int i = 0; i < no_of_levels; i++)
     {
         int x = i * img.width / no_of_levels;
         int y = img.height - (level[i] * (img.height * 8 / 10) / maxval);
         if (i > 0)
         {
             img.drawLine(prev_x, prev_y, x, y, 0, 255, 0, 0);
         }
         prev_x = x;
         prev_y = y;
     }
 }
示例#2
0
        //------------------------------------------------------------------------------------------------------------------------
        //detects the centre points of image
        //------------------------------------------------------------------------------------------------------------------------
        public int detectBlobCentres(classimage sourceimage, classimage tempimage, int min_volume, ref int average_volume, ref int average_radius, int[,] blob_data, int no_of_angles, classimage colour_image, int[,,] radius_lookup)
        {
            int x,y,no_of_blobs;
            int tx,ty,bx,by,cx,cy;
            long pixels,av_r,av_g,av_b,av_x,av_y,av_vol,av_rad;

            clear();
            tempimage.clear();
            no_of_blobs=0;
            av_vol=0;
            av_rad=0;
            for (x=1;x<width-1;x++)
            {
                for (y=1;y<height-1;y++)
                {
	                if (sourceimage.image[x,y,0]>0)
	                {
		                pixels=0;
	                    av_x=0; av_y=0;
		                av_r=0; av_g=0; av_b=0;
		                tx=x; ty=y; bx=x; by=y;
	                    floodFill(x,y,0,100,100,100,ref tx,ref ty,ref bx,ref by,ref pixels,ref av_r,ref av_g,ref av_b,sourceimage,ref av_x,ref av_y,false,0,tempimage,colour_image);
		                if (pixels>min_volume)
		                {
		                    cx = (int)(av_x / pixels);
		                    cy = (int)(av_y / pixels);
		                    image[cx,cy,0]=255;
		                    image[cx,cy,1]=255;
		                    image[cx,cy,2]=255;
		                    av_vol += pixels;
		                    av_rad += (((bx-tx) + (by-ty))/2);

                            //update blob data
		                    if (no_of_blobs<2000)
		                    {
		                        blob_data[no_of_blobs,0] = (int)pixels;
		                        blob_data[no_of_blobs,1] = cx;
		                        blob_data[no_of_blobs,2] = cy;
		                        blob_data[no_of_blobs,3] = bx-tx;
		                        blob_data[no_of_blobs,4] = by-ty;
			                    blob_data[no_of_blobs,5] = (int)(av_r / pixels);
			                    blob_data[no_of_blobs,6] = (int)(av_g / pixels);
			                    blob_data[no_of_blobs,7] = (int)(av_b / pixels);
                                if (no_of_angles>1) tempimage.getBlobShape(no_of_angles,cx,cy,tx,ty,bx,by,blob_data,no_of_blobs,8,radius_lookup);
		                    }

		                    no_of_blobs++;
		                }
		                tempimage.clearArea(tx,ty,bx,by);
	                }
	            }
            }

            if (no_of_blobs>0)
            {
                average_volume = (int)(av_vol / no_of_blobs);
	            average_radius = (int)(av_rad / no_of_blobs);
            }
            return(no_of_blobs);
        }