Hi, I have curve fitted an histogram using the gaussian function. Now I would like to know how to extract a series of cell diameters from the gaussian fit.
Check The Code:
clc; clear all; close all; BW = imread('../resources/images/gaussianfitqa3.png'); [nr,nc,layers] = size(BW); %% converting the image to 2d so the image can be labledd %% if layers>1 BW = BW(:,:,1); end % end of lablling %%%%%%%%%%%%%%%%% binaryimage = BW < 128; bw = logical(binaryimage); imwrite(bw, 'imagetoapp.jpg'); %% lablelling the image %%%%%% [labeledimage, numberofblobs] = bwlabel(binaryimage,8); props = regionprops(labeledimage, 'Equivdiameter'); x = numel(props); y = zeros(x,1); for i = 1:1:length(props) y(i,1) = struct2array(props(i,1)); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% LAbled image to rgb colouredimage = label2rgb(labeledimage,'jet', [0,0,0.5]); coloredLabelsImage = label2rgb (labeledimage, 'jet', 'k', 'shuffle'); imshowpair(labeledimage,colouredimage,'montage') hold on %% generating histogram and curve fitting it using gaussian function%%%%%%%%% figure() y1 = histogram(y,45); values = y1.Values; a=y1.BinEdges; for i = 1 : length(a)-1 b(i) = mean(a(i:i+1)); end [barheights, position] = hist(y,45); positiontranspose = position'; valuestranspose = values'; gauss = 'd + a*exp(-(1/2)*((x-b)/c)^2)' startpoints = [40 20 10 0.5]; myfit = fit(positiontranspose,valuestranspose,gauss,'start',startpoints); hold on plot(myfit) z(:,1) = myfit(x); zt=myfit(b); %% plot properties xlabel('cell diamters') ylabel('frequency') hold on; plot(b, zt, 'r*') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%
%% generating histogram and curve fitting it using gaussian function%%%%%%%%% figure() y1 = histogram(y,45); values = y1.Values; a=y1.BinEdges; for i = 1 : length(a)-1 b(i) = mean(a(i:i+1)); end [barheights, position] = hist(y,45); positiontranspose = position'; valuestranspose = values'; gauss = 'd + a*exp(-(1/2)*((x-b)/c)^2)'
gauss = 'd + a*exp(-(1/2)*((x-b)/c)^2)'
startpoints = [40 20 10 0.5]; myfit = fit(positiontranspose,valuestranspose,gauss,'start',startpoints); hold on plot(myfit) z(:,1) = myfit(x); zt=myfit(b); %% plot properties xlabel('cell diamters') ylabel('frequency') hold on; plot(b, zt, 'r*')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.