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
Walter Roberson 2016 年 1 月 11 日

0 投票

plot(t, average_red_value_vector);
xlabel('time');
ylabel('Intensity');

10 件のコメント

Gee Cheng Mun
Gee Cheng Mun 2016 年 1 月 11 日
Thank you for the help! How can I declare the value of t? For example, t is the range between 320 and 400 seconds.
Walter Roberson
Walter Roberson 2016 年 1 月 11 日
t = 320:400; %if consecutive integers
Gee Cheng Mun
Gee Cheng Mun 2016 年 1 月 12 日
編集済み: Gee Cheng Mun 2016 年 1 月 12 日
Okay! How about the average red vector? I have different average values measured. How can I specify each average value in the graph?
Walter Roberson
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
Gee Cheng Mun 2016 年 1 月 12 日
編集済み: Gee Cheng Mun 2016 年 1 月 12 日
I have different folders of images, thus I have to calculate the average of red pixels for each individual folder of images. I have calculated the average of red counts for each folder, so I need to plot a graph of red counts vs time.
Walter Roberson
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
Gee Cheng Mun 2016 年 1 月 12 日
編集済み: Gee Cheng Mun 2016 年 1 月 12 日
The time taken was given by my collaborators. From 540 -3780 sec. How can I input that in MATLAB as the folder_times?
Walter Roberson
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
Gee Cheng Mun 2016 年 1 月 12 日
編集済み: Gee Cheng Mun 2016 年 1 月 12 日
The folders are named as shown below and they have an equal interval of 180 sec. Those timings below do not have a text file. How can I display those timings in the graph?
Frame 13: 540 - 720
Frame 14: 720 - 900
Frame 15: 900 - 1080
Frame 16: 1080 - 1260
Frame 17: 1260 - 1440
Frame 18: 1440 - 1620
Walter Roberson
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 ExchangeConvert Image Type についてさらに検索

質問済み:

2016 年 1 月 11 日

コメント済み:

2016 年 1 月 12 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by