图像分析火焰边缘检测曲线拟合不总是适用于MatLab
我正试图找出如何在Matlab中制作一个程序来检测火焰的边缘,以便比较它们的火焰形状。我有一半的时间能够让这个程序正常工作。程序读取文件,将其转换为黑白,然后我发现图像分析火焰边缘检测曲线拟合不总是适用于MatLab,matlab,image-processing,curve-fitting,edge-detection,Matlab,Image Processing,Curve Fitting,Edge Detection,我正试图找出如何在Matlab中制作一个程序来检测火焰的边缘,以便比较它们的火焰形状。我有一半的时间能够让这个程序正常工作。程序读取文件,将其转换为黑白,然后我发现bwbounders函数出现了问题(我想) 根据图片的不同,它有时会起作用,有时则不起作用,如下图所示 任何人能给我的任何帮助都将不胜感激。我在这里苦苦挣扎,想弄清楚我做错了什么 clear, clc , close all %% Specify the folder where the files live. %myFolder =
bwbounders
函数出现了问题(我想)
根据图片的不同,它有时会起作用,有时则不起作用,如下图所示
任何人能给我的任何帮助都将不胜感激。我在这里苦苦挣扎,想弄清楚我做错了什么
clear, clc , close all
%% Specify the folder where the files live.
%myFolder = 'D:\Try';
myFolder = 'D:\Try\PicNamed\SpTestTry\hope';
%% Check to make sure that folder actually exists.
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
%% Get a list of all files in the folder with the pattern
filePattern = fullfile(myFolder, '*.jpg'); % Change to whatever need.
theFiles = dir(filePattern);
line = cell(length(theFiles), 1) ;
rValue = cell(length(theFiles),1);
baseFileName = theFiles(1).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
imageArray = imread(fullFileName);
% getting the rectanglur cords to crop the images
[I2, rect] = imcrop(imageArray);
%% Run Loop
for k = 1 : length(theFiles)
%Pulling in multiple Images from folder
baseFileName = theFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
imageArray = imread(fullFileName);
%% Cropping Image with Rect Cords
Icrop = imcrop(imageArray,rect);
%% convert to bw
BW = im2bw(Icrop, graythresh(Icrop));
%% Get Boundries
boundaries = bwboundaries(BW);
% putting in x and y cord
x = boundaries{1}(:, 2);
y = boundaries{1}(:, 1);
%% Curve Fit
%pulling up picture of x,y plot to determing where base of flame is
figure
plot(x, y)
% cutting off bottom of flame edge so we can do curve fit
prompt = '(******) cut off line = ';
cutnum = input(prompt);
indices = find(abs(y)>cutnum);
y(indices) = NaN;
y(indices) = [];
x(indices) = [];
%% Looking for repate x values, averaging them together, and replacing with 1 x value
uc1 = unique( x ) ;
mc2 = accumarray( x, y, [], @mean ) ;
newData = [uc1, mc2(uc1)];
%% splitting AA into two sperate matricies, i.e. x/y cordinates
y = newData(:,2);
x = newData(:,1);
%% Creating a line Based off of the averaged x and y cords
[p,S] = polyfit(x,y,4); % 4th degree polynomail
line{k} = p;
rValue{k} = S.normr;
Rsquared{k}=1-S.normr^2/norm(y-mean(y))^2;
close all
clear BW
clear x
clear y
end
如果你不提供数据,没有人能相信我是一个新用户,在获得更多代表之前,我上传的链接不能超过两个。我已经将两个图表合并,并链接了一张较小的图片。对这些问题感到抱歉。希望这就足够了。我会设法上传所有的原件。现在我已经编辑好了,te系统允许你添加更多吗?你能添加一个坏的图片吗?我不知道如何添加更多的图片到这个帐户,因为我今天刚刚创建了它(他们不允许我发布更多的图片/链接到图片)图形图片是好的和坏的。右边好,左边坏。右边的图片有一个很好的“抛物线”火焰形状,左边是从遍布各地的数据点绘制的一条线。不同的火焰图片在相似的设置下,使用相同的代码,但得到不同的图形线。