title: Creat a circular ROI and account for partial pixel values
body: <p>I have a image of low resolution, 128x128 pixels. I need to obtain the mean value of a circle ROI, in order to do that I use the easy method:</p>
  
  <pre><code>%% Draw circle ROI 
  t = 0:pi/500:2*pi;
  xi = ((R0/pixelSize)*cos(t)+63.5+x0+((Rsphere)/pixelSize)*cos(theta))*4;
  yi = ((R0/pixelSize)*sin(t)+63.5+y0+((Rsphere)/pixelSize)*sin(theta))*4;
  
  %% Calculate roi statistics
  line(xi,yi,'LineWidth',1,'Color',color);
  ROImask = poly2mask(xi,yi, size(im,1),size(im,2));
  ptROI = find(ROImask);
  ROImean = mean(im(ptROI));
  </code></pre>
  
  <p>The problem here is that using this method I don't account for the partial value of a pixel in the ROI, as can be seen in the image.</p>
  
  <p>Is there any direct way to obtain the mean of the ROI weighting the value of the pixels?</p>
  
  <p>Thanks</p>
  
  <p><a href="https://i.stack.imgur.com/zXR0u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zXR0u.png" alt="Artististic impression of the problem"></a></p>