Das ist auch genau das, wonach ich suche. Bei meinen Bildern funktioniert das aber leider nicht. Ich habe den Vertikalen Anteil erstmals aus dem Programm entfernt.
Genauso in der 1. Zeile
n=61;
for i=1:n, %es werden 22 Images durchgezählt
filename = ['Test_' num2str(i) '.bmp']; %Ordner der Bilder auswählen,
%num2str(i) legt bei den Bildern die _1 _2 usw. an
[Bild, colorMap] = imread(filename); %Ändert Bild um, speichert es ab und liest es wieder ein
colormap(colorMap);
colorbar;
Raw_Img = ind2rgb(Bild, colorMap);
imwrite(Raw_Img,'Ppapier.bmp');
filename = ['Ppapier.bmp'];
Raw_Img=imread(filename);
E(i)=SpeckleSizeOrginal(Raw_Img);
delete('Ppapier.bmp');
end
%By: Joel Sleppy
%jdsleppy [AT] wustl.edu
%July 23, 2009
%SpeckleSize determines the speckle size from an image using
%autocovariance.
%SpeckleSize takes as an input a H by W by 3 matrix of integer values
%between 0 and 255, where H is the height of the image, W is the width of
%the image, and the three values are the RGB values for each pixel. Its
%outputs are the FWHM and 1/e^2(beam waist) values of Gaussian fits to two arrays
%generated by the sums of the normalized autocovariances of 1)all rows in
%the image and 2)all columns in the image. From the FWHM size or the 1/e^2
%size, these arrays tell you the horizontal and vertical speckle sizes.
%Also, it outputs goodness of fit statistics (such as R-squared).
%HFWHM is the horizontal speckle size per FWHM method, VeSquared is the
%vertical speckle size per 1/e^2 method, etc.
%The easiest way to obtain an RGB matrix is to use the image processing
%toolbox to open an image from file and use 'export to workspace.'
%This is adapted from Haibo Lin's University of Missouri Ph.D thesis,
%"Speckle Mechanism in Holographic Optical Coherence Imaging"
%NOTE: The function works best when the entire imageisfull of speckle
%with no long-range background (such as a Gaussian envelope).
%If this is the case, H and V will have a needle-like peak in the center
%with little fluctuation elsewhere. If the needle-like peak sits on top of
%a 'hill,' either limit your FWHM calculations to the needle-like peak or crop the
%image so it isfull of uniform speckle (no extra black background). The 'hills'
%are caused by the function processing the Gaussian envelope (or 'speckle within speckle') as one
%large spot against the black background. See GaussianSubtractSpeckleSize
%if needed.
%NOTE: The fitis not very good if the adjusted R-squared value is not near
%one! Check this after every run.
M=size(SpeckleRGB,1); %height of area
N=size(SpeckleRGB,2); %width of area
B=rgb2gray(SpeckleRGB); %produces grayscale image(intensity map)
B=double(B); %typecasts the values as doubles
E=B(1,:); %creates an array with the values of row 1
s=size(xcov(E)); %finds the size of the autocovariance array
D=zeros(s); %creates an empty array of size s
D=double(D); %typecasts the values as doubles
for i=1:M;
C=B(i,:);
D=imadd(D,xcov(C,'coeff')); %sums the xcov arrays forall rows into D
end;
H=(D/max(D)); %the finished horizontal product, H, is normalized
%H and V are fit to Gaussians and the speckle sizeis extracted from the
%fits.
gauss1 = fittype('gauss1'); %sets up the Gaussian curve fitting
excludeLowH = excludedata(helper1',H','range',[.2,1]); %excludes the noise from outside the speckle
optionsH = fitoptions(gauss1);
optionsH.Exclude = excludeLowH;
[HFit] = fit(helper1',H',gauss1, optionsH); %performs the fits
%The SpeckleSize code technically does not find the FWHM and 1/e2 widths of
%the Gaussian fits, but rather the widths at which the Gaussians fall to
%values of .5 and 1/e^2. This provides a better idea of the speckles size
%even when the Gaussians amplitude is not unity, as expected for a perfect
%fit of the normalized data, but can produce unexpected trends...
HFWHM = (2*(HFit.c1)*sqrt(-log(.5/(HFit.a1)))); %FWHM values (Full width when the fit = .5)
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.