예제 #1
0
파일: main.cpp 프로젝트: mrkn/photo_scan
void
coarse_graining(boost::gil::rgb8_image_t const& source, boost::gil::rgb8_image_t& destination)
{
  int dst_width  = (source.width()  + 7) / 8;
  int dst_height = (source.height() + 7) / 8;
  destination = boost::gil::rgb8_image_t(dst_width, dst_height);

  boost::gil::rgb8c_view_t::xy_locator in_loc = boost::gil::const_view(source).xy_at(0, 0);
  boost::gil::rgb8_view_t::xy_locator dst_loc = boost::gil::view(destination).xy_at(0, 0);

  for (int y = 0; y < dst_height; ++y) {
    for (int x = 0; x < dst_width; ++x) {
      double r = 0, g = 0, b = 0;
      int n = 0;
      for (int i = 0; i < 8 && 8*y + i < source.height(); ++i) {
        for (int j = 0; j < 8 && 8*x + j < source.width(); ++j, ++n) {
          r += in_loc(8*x + j, 8*y + i)[2];
          g += in_loc(8*x + j, 8*y + i)[1];
          b += in_loc(8*x + j, 8*y + i)[0];
        }
      }
      g /= n;
      if (g <= 24) {
        g = 0;
        r = b = 255;
      }
      else {
        r /= n;
        b /= n;
      }
      dst_loc(x, y) = boost::gil::rgb8_pixel_t(r, g, b);
    }
  }
}
예제 #2
0
/*
 * Dispatch enable/disable 
 */
SYSCALL ER tk_dis_dsp_impl( void )
{
	CHECK_CTX(!in_loc());

	knl_dispatch_disabled = DDS_DISABLE;

	return E_OK;
}
예제 #3
0
/*
 * Dispatch enable 
 */
SYSCALL ER tk_ena_dsp_impl( void )
{
	CHECK_CTX(!in_loc());

	knl_dispatch_disabled = DDS_ENABLE;
	if ( knl_ctxtsk != knl_schedtsk ) {
		knl_dispatch();
	}

	return E_OK;
}
예제 #4
0
파일: cpu_calls.c 프로젝트: kidasan/tkernel
/*
 * Dispatch enable
 */
SYSCALL ER _tk_ena_dsp( void )
{
	CHECK_CTX(!in_loc());

	BEGIN_CRITICAL_SECTION
	dispatch_disabled[get_prid()] = DDS_ENABLE;
	ready_queue_top(&ready_queue, schedtsk);
	END_CRITICAL_SECTION

	return E_OK;
}
예제 #5
0
파일: cpu_calls.c 프로젝트: kidasan/tkernel
/*
 * Dispatch enable/disable
 */
SYSCALL ER _tk_dis_dsp( void )
{
	BOOL	done = FALSE;
	UINT	prid;

	CHECK_CTX(!in_loc());

  retry:
	BEGIN_CRITICAL_SECTION;
	prid = get_prid();
	if ( (ctxtsk[prid]->state & TS_SUSPEND) == 0 ) {
		dispatch_disabled[prid] = DDS_DISABLE;
		done = TRUE;
	}
	END_CRITICAL_NO_DISPATCH;
	if ( !done ) {
		goto retry;
	}

	return E_OK;
}
예제 #6
0
/*
 * Refer system state
 */
SYSCALL ER tk_ref_sys_impl( T_RSYS *pk_rsys )
{
	if ( in_indp() ) {
		pk_rsys->sysstat = TSS_INDP;
	} else {
		if ( in_qtsk() ) {
			pk_rsys->sysstat = TSS_QTSK;
		} else {
			pk_rsys->sysstat = TSS_TSK;
		}
		if ( in_loc() ) {
			pk_rsys->sysstat |= TSS_DINT;
		}
		if ( in_ddsp() ) {
			pk_rsys->sysstat |= TSS_DDSP;
		}
	}
	pk_rsys->runtskid = ( knl_ctxtsk != NULL )? knl_ctxtsk->tskid: 0;
	pk_rsys->schedtskid = ( knl_schedtsk != NULL )? knl_schedtsk->tskid: 0;

	return E_OK;
}