Esempio n. 1
0
int Roi::overlapArea(Roi checkRoi){
	int overlap = 0;
	// Calulate the intersection of the two roi
	overlap = max(0,min(lowerRightX, checkRoi.endX())-max(upperLeftX,checkRoi.startX())) * max(0,min(lowerRightY, checkRoi.endY())-max(upperLeftY,checkRoi.startY()));
	//overlap = max(0,min(upperLeftX, checkRoi.startX())-max(lowerRightX,checkRoi.endX())) * max(0,min(upperLeftY, checkRoi.startY())-max(lowerRightY,checkRoi.endY()));
	return overlap;
}
Esempio n. 2
0
bool Roi::pinit(Roi R, float percent)
{
  float t = 2*percent/100*R.height(); // twice the percent is the total range of the random number
  int max_twice_offset = (int) t; // truncate
  int ulxoffset = rand()%max_twice_offset - t/2; // allow both positive and negative offsets
  int ulyoffset = rand()%max_twice_offset - t/2; // allow both positive and negative offsets
  int lrxoffset = rand()%max_twice_offset - t/2; // allow both positive and negative offsets
  int lryoffset = rand()%max_twice_offset - t/2; // allow both positive and negative offsets
  
  upperLeftX  = R.startX() + ulxoffset;
  upperLeftY  = R.startY() + ulyoffset;
  lowerRightX = R.endX()   + lrxoffset;
  lowerRightY = R.endY()   + lryoffset;
  roiValue    = R.label();
  randomlyGenerated = true;
  return(true);
}