


compute brightness fraction for particle Syntax: brightFraction = computeBrightFraction(image, cartX, cartY) This function takes the original image together with a boundary curve structure (bnd) to do the following. First, extract the sub image of the particle. Secondly compute a circular filter that selects about 70% of the center area. Thirdly, apply a threshold to this part and calculate the fraction of bright pixels by total pixels of the cneter area. If required a modified image is returned in a second output argument. This image leaves the center area as it was provided and inverts the outer area. The brightnes fraction is used to identify bubbles. Therefore, the roundness value is also required. See also: obtainBnd


0001 function [brightFraction particleImageOut] = ... 0002 computeBrightFraction(image, cartX, cartY, sizeFraction, threshold) 0003 % compute brightness fraction for particle 0004 % 0005 % Syntax: brightFraction = computeBrightFraction(image, cartX, cartY) 0006 % 0007 % This function takes the original image together with a boundary curve 0008 % structure (bnd) to do the following. First, extract the sub image of 0009 % the particle. Secondly compute a circular filter that selects about 70% 0010 % of the center area. Thirdly, apply a threshold to this part and 0011 % calculate the fraction of bright pixels by total pixels of the cneter 0012 % area. 0013 % 0014 % If required a modified image is returned in a second output argument. 0015 % This image leaves the center area as it was provided and inverts the 0016 % outer area. 0017 % 0018 % The brightnes fraction is used to identify bubbles. Therefore, the 0019 % roundness value is also required. 0020 % 0021 % See also: obtainBnd 0022 0023 % The elk-library: convex geometry applied to crystallization modeling. 0024 % Copyright (C) 2012 Alexander Reinhold 0025 % 0026 % This program is free software: you can redistribute it and/or modify it 0027 % under the terms of the GNU General Public License as published by the 0028 % Free Software Foundation, either version 3 of the License, or (at your 0029 % option) any later version. 0030 % 0031 % This program is distributed in the hope that it will be useful, but 0032 % WITHOUT ANY WARRANTY; without even the implied warranty of 0033 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0034 % General Public License for more details. 0035 % 0036 % You should have received a copy of the GNU General Public License along 0037 % with this program. If not, see <http://www.gnu.org/licenses/> 0038 0039 % get particle image 0040 particleImage = image(max(cartY):-1:min(cartY), ... 0041 min(cartX):max(cartX)); 0042 0043 % size and coordinates 0044 xSize = size(particleImage, 1); 0045 ySize = size(particleImage, 2); 0046 xCenter = round(xSize/2); 0047 yCenter = round(ySize/2); 0048 0049 % construct filter 0050 [Y X] = meshgrid(1:ySize, 1:xSize); 0051 filterImage = sqrt((X-xCenter).^2 + (Y-yCenter).^2) < ... 0052 0.5*sizeFraction*min([xSize ySize]); 0053 imageFiltered = (particleImage > threshold) & filterImage; 0054 0055 % apply filter to brightness fraction 0056 brightFraction = sum(imageFiltered(:)) / sum(filterImage(:)); 0057 0058 % return image if required 0059 if nargout == 2 0060 particleImageOut = ... 0061 uint8(particleImage) .* uint8(filterImage) + ... 0062 uint8(255 - particleImage) .* uint8(~filterImage); 0063 end 0064 0065