關於這段code是如何達到顯示color histogram的?已回收
大家好,我前些時候在code job板發了一個案子
是自己在研究上需要用到的,有關影像分析部分的project
由於我本身並非念資工系背景,但是研究上有需要所以才發案請人幫忙
目前也在一邊研究別人code一邊學習中
我想問的就是下面這段code是如何達到"取得image的histogram的功能"
(%%後的中文註解是我稍微研究後認為的結果,麻煩強者板有幫忙指正,感謝)
function hist = gethist(file_name, type) %% 定義取得質方圖的函式get_hist?
firstframe = imread(file_name); %% 不是很了解firstframe的功能?
hist = get_hist(firstframe, type); %% 是為了定義的get_hist可以read image?
end
function color_hist = get_hist(array, type) %% 將color_hist這個函式的結果傳給取
%% 得質方圖的函式get_hist?
ss = size(array);
hist = zeros(ss(1),ss(2)); %% 不是很懂這兩行...orz
if type == 'RGB'
% use 64 (4*4*4) bins to do histogram
hist(:,:) = floor(double(array(:,:,1))/64)*16 +
floor(double(array(:,:,2))/64)*4 +
floor(double(array(:,:,3))/64);
color_hist = zeros(1,64);
%% 上面四行就是最不了解的地方...
%% 我只知道這個做法是用RGB各4bins
%% 所以total = 4*4*4 = 64bins 來
%% 表示所有顏色的combination的分布
還有因為image的dataset圖片大小不同,所包含的pixels數目也不同
所以要normalization
但是我也不是很了解下面這段code是怎麼做到的
for i =1:ss(1)
for j = 1:ss(2)
color_hist(hist(i,j)+1) = color_hist(hist(i,j)+1)+1;
end
end
color_hist = double(color_hist) / sum(color_hist);
先感謝利害的強者回答了 orz 非常感恩!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 71.95.57.98
→
05/14 14:30, , 1F
05/14 14:30, 1F
→
05/14 14:30, , 2F
05/14 14:30, 2F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 4 篇):