void
Scene_implicit_function_item::direct_draw() const
{
  
  draw_function_grid(red_color_ramp_, blue_color_ramp_);
  draw_bbox();
}
Example #2
0
void join_subimages(subimage_t * srcsiarray, pngimage_t * destimg, int slices, int pixelborder)
{
  int xstart, i, j, imgno, wreal, bbnum;
  xstart = 0;

  for(imgno=0; imgno<slices; imgno++)
  {
    wreal = srcsiarray[imgno].w - ( ((imgno==0)||(imgno==slices-1)) ? pixelborder : 2*pixelborder );
//printf("imgno=%d di %d - w=%d h=%d\n", imgno, slices, srcsiarray[imgno].w, srcsiarray[imgno].h);
    for(i=0; i<srcsiarray[imgno].h; i++)
    {
      for(j=0; j<wreal; j++)
      {
         int r, g, b;
         subimage_getpixel(&srcsiarray[imgno], j + ( imgno!=0 ? pixelborder : 0 ), i, &r, &g, &b);
         imageSetPixel(destimg, xstart+j, i, r, g, b);
      }
    }
    //draw bboxes
    for(bbnum=0; bbnum<srcsiarray[imgno].Nbbox; bbnum++)
    {
       int realxupleft, realyupleft, width, height;
       width = srcsiarray[imgno].bboxData[bbnum*4+2];
       height = srcsiarray[imgno].bboxData[bbnum*4+3];
       realxupleft = srcsiarray[imgno].bboxData[bbnum*4+0] - (imgno!=0 ? pixelborder : 0) + xstart;
       realyupleft = srcsiarray[imgno].bboxData[bbnum*4+1];
       draw_bbox(destimg, realxupleft, realyupleft, width, height);
    }

    xstart += wreal;
  }

}
Example #3
0
static void
drawfileNeWS(const char *cp, FILE *psfile)
{
    char buffer[1025];
    int blen;
    struct sigaction orig;

    if (!NeWS_active) {
	fclose(psfile);
	return;
    }

    if (globals.debug & DBG_PS)
	printf("printing file %s\n", cp);

    sigpipe_error = False;
    for (;;) {
	blen = fread(buffer, sizeof(char), 1024, psfile);
	if (blen == 0) break;
	NeWS_send(buffer, blen);
	if (sigpipe_error || (globals.ev.flags & NeWS_ev_mask))
	    break;
    }
    fclose(psfile);

    if (sigpipe_error) {
	fputs("NeWS died unexpectedly.\n", stderr);
	destroyNeWS();
	draw_bbox();
    }
}
Example #4
0
void draw_coco(image im, float *pred, int side, char *label)
{
    int classes = 1;
    int elems = 4+classes;
    int j;
    int r, c;

    for(r = 0; r < side; ++r){
        for(c = 0; c < side; ++c){
            j = (r*side + c) * elems;
            int class = max_index(pred+j, classes);
            if (pred[j+class] > 0.2){
                int width = pred[j+class]*5 + 1;
                printf("%f %s\n", pred[j+class], "object"); //coco_classes[class-1]);
                float red = get_color(0,class,classes);
                float green = get_color(1,class,classes);
                float blue = get_color(2,class,classes);

                j += classes;

                box predict = {pred[j+0], pred[j+1], pred[j+2], pred[j+3]};
                predict.x = (predict.x+c)/side;
                predict.y = (predict.y+r)/side;
                
                draw_bbox(im, predict, width, red, green, blue);
            }
        }
    }
    show_image(im, label);
}
Example #5
0
static void
post_send(void)
{
    if (sigpipe_error) {
	fputs("NeWS died unexpectedly.\n", stderr);
	destroyNeWS();
	draw_bbox();
    }
}
Example #6
0
SkPicture* SkDrawable::onNewPictureSnapshot() {
    SkPictureRecorder recorder;

    const SkRect bounds = this->getBounds();
    SkCanvas* canvas = recorder.beginRecording(bounds, nullptr, 0);
    this->draw(canvas);
    if (false) {
        draw_bbox(canvas, bounds);
    }
    return recorder.endRecording();
}
Example #7
0
void SkDrawable::draw(SkCanvas* canvas, const SkMatrix* matrix) {
    SkAutoCanvasRestore acr(canvas, true);
    if (matrix) {
        canvas->concat(*matrix);
    }
    this->onDraw(canvas);

    if (false) {
        draw_bbox(canvas, this->getBounds());
    }
}
Example #8
0
void save_image(Image &img, const ublas::matrix<int> &bboxlist,int level, const char *filename,float scale_factor)
{
  Image imgcopy(img);
  draw_bbox(imgcopy,bboxlist,level,scale_factor);
  imgcopy.save(filename); 
}
Example #9
0
void display_image(Image &img, const ublas::matrix<int> &bboxlist, int level,float scale_factor)
{
  Image imgcopy(img);
  draw_bbox(imgcopy,bboxlist,level,scale_factor);
  imgcopy.display();
}
Example #10
0
static void region_labeling(uint8_t* dst)
{
  uint8_t tmp_buf[SZ];
  
  /* input picture info */
  struct OSC_PICTURE picin =
  {
    .data = IMAGE(DILATION),
    .width = NC,
    .height = OSC_CAM_MAX_IMAGE_HEIGHT / 2u,
    .type = OSC_PICTURE_GREYSCALE
  };

  /* temporary binary image */
  struct OSC_PICTURE picout =
  {
    .data = tmp_buf,
    .width = NC,
    .height = OSC_CAM_MAX_IMAGE_HEIGHT / 2u,
    .type = OSC_PICTURE_BINARY
  };
  
  /* region labeling info */
  struct OSC_VIS_REGIONS region_info;
  
  /* make a binary image */
  OscVisGrey2BW(&picin, &picout, 0x80, false);
  
  /* now do the region labeling */
  OscVisLabelBinary(&picout, &region_info);
  
  /* feature extraction */
  OscVisGetRegionProperties(&region_info);
  
  /* now copy the grayscale image to the labeling image */
  memcpy(dst, IMAGE(GRAYSCALE), SZ);
  
  /* abuse the picin picture info to draw the bounding boxes */
  picin.data = dst;
  draw_bbox(&picin, &region_info, 0x80);
  
  /* set the number of objects in the web gui */
  data.ipc.state.objectcount = region_info.noOfObjects;
}

static uint8_t otsu(const uint8_t* img)
{
  uint8_t ret;
  uint32_t histogram[256];
  uint32_t k, g;
  uint32_t w0, w1;
  uint32_t mu0s, mu1s;
  float mu0, mu1;
  float sigma_b, sigma_max;

  /* initialise the histogram with zero */
  memset(histogram, 0, sizeof(histogram));

  /* calculate the histogram */
  imhist(histogram, img);
  
  sigma_max = 0.0f;
  
  for(k = 0; k < 256; k++)
  {
    w0 = w1 = 0;
    mu0s = mu1s = 0;
    for(g = 0; g < 256; g++)
    {
      if(g <= k)
      {
        w0 += histogram[g];
        mu0s += histogram[g] * g;
      }
      else
      {
        w1 += histogram[g];
        mu1s += histogram[g] * g;
      }
    }
    mu0 = ((float)mu0s / (float)w0);
    mu1 = ((float)mu1s / (float)w1);
    
    sigma_b = ((float)(w0 * w1)) * (mu0 - mu1) * (mu0 - mu1);
    if(sigma_b > sigma_max)
    {
      sigma_max = sigma_b;
      ret = (uint8_t)k;
    }
  }
  
  return ret;
}
Example #11
0
static void
drawbeginNeWS_box(int xul, int yul, const char *cp)
{
    drawbeginNeWS(xul, yul, cp);
    draw_bbox();
}