How to plot an intensity graph?
显示 更早的评论
I have obtained an average value of red pixel count as well the time involved. How do I plot an intensity graph?
回答(1 个)
Walter Roberson
2016-1-11
plot(t, average_red_value_vector);
xlabel('time');
ylabel('Intensity');
10 个评论
Gee Cheng Mun
2016-1-11
Walter Roberson
2016-1-11
t = 320:400; %if consecutive integers
Gee Cheng Mun
2016-1-12
编辑:Gee Cheng Mun
2016-1-12
Walter Roberson
2016-1-12
average_red_value_vector should be the vector of averages, however you obtain them. This would require that you have multiple things you were averaging together at each time, which is certainly a possibility, but I wonder if what you have instead is the counts, something like
dinfo = dir('ghostkidney_*.tiff');
for K = 1 : length(dinfo)
thisfile = dinfo(K).name;
thisimage = imread(thisfile);
meets_red_threshold = thisimage(:,:,1) > 180 & thisimage(:,:,2) < 60 & thisimage(:,:,3) < 60; %strong red compared to G or B
red_counts(K) = nnz(meets_red_threshold);
t(K) = (K-1)/24; %24 frames per second
end
plot(t, red_counts)
Gee Cheng Mun
2016-1-12
编辑:Gee Cheng Mun
2016-1-12
Walter Roberson
2016-1-12
编辑:Walter Roberson
2016-1-12
projectdir = fullfile(pwd, 'MyProject'); %or use an absolute path
folder_info = dir(projectdir);
folder_info(~[folder_info.isdir]) = []; %ignore non-folders
folder_info( ismember({folder_info.name}, {'.', '..'}) ) = []; %remove . and .. directories
num_folders = length(folder_info);
avg_counts = zeros(1, num_folders);
folder_times = zeros(1, num_folders);
for fold_idx = 1 : num_folders
this_folder = fullfile( projectdir, folder_info(fold_idx).name );
folder_times(fold_idx) = ... you didn't say how you know the time
file_info = dir( fullfile(this_folder, '*.tiff') ); %example image name pattern
num_files = length(file_info);
red_count = 0;
for file_idx = 1 : num_files
thisfile = fullfile(this_folder, file_info(file_idx).name );
thisimage = imread(thisfile);
%determine which pixels count as red
meets_red_threshold = thisimage(:,:,1) > 180 & thisimage(:,:,2) < 60 & thisimage(:,:,3) < 60; %strong red compared to G or B ??
red_count = red_count + nnz(meets_red_threshold);
end
avg_count = red_count / num_files;
avg_counts(fold_idx) = avg_count;
end
plot(folder_times, avg_counts)
Gee Cheng Mun
2016-1-12
编辑:Gee Cheng Mun
2016-1-12
Walter Roberson
2016-1-12
Are they equal intervals in seconds? Does the folder name include the time in it somewhere? Do the file names of the images include the time in them somewhere? Is there a text file or xls file that has the times recorded?
Gee Cheng Mun
2016-1-12
编辑:Gee Cheng Mun
2016-1-12
Walter Roberson
2016-1-12
In the code I give above, replace
folder_times(fold_idx) = ... you didn't say how you know the time
with
timestr = regexprep( folder_info(fold_idx).name, {'^[:]+:\s+', '\s+-\s+\d+$'}, {'', ''});
folder_times(fold_idx) = str2double(timestr);
类别
在 帮助中心 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!