Re: 關於這段code是如何達到顯示color histogram的?已回收
※ 引述《transpotting (transpotting)》之銘言:
: 感謝回答,不過我也才發現原來這邊做了顏色加權和轉灰階的動作?
: : hist(:,:) = floor(double(array(:,:,1))/64)*16 +
: : floor(double(array(:,:,2))/64)*4 +
: : floor(double(array(:,:,3))/64);
array(:,:,1)= 影像的R
..........2 = B
..........3 = G
本來的影像的數值分佈是 0:255
他作的動作是
紅色R
0: (255 / 64 * 16)
所以分佈為
0:64
綠色G
分佈改為
0:16
藍色B
改成
0:4
然後相加
基本上就是 加權後的灰階影像 (加權比例R:G:B=16:4:1)
如果說照你講的要RGB分開作
那histogram 要分開作RGB三個
也就是output變成3組
這樣後面不知道 會不會牽一髮動全身...
或者有另一種作法
把RGB三個連續作成一個histogram
原本的histogram
x軸應該是0:255(各色灰階)
轉成x=0:767 (767=256*3-1)
然後 0:255放R 256:511放G 512:767放B
只是不知道 後面的計算 這樣的RGB能不能被接受
RGB的顏色資訊不會失真
但是 出來的color_hist本來是 n*64 會變成 n*768
不過還是回到上一段結論...
不知道 後面的程式 吃不吃這組histogram
: 如果我只是要單純取得RGB三種顏色的color histogram
: 應該要怎樣改寫才行呢?
: ※ 引述《DigiPrince (幻無影)》之銘言:
: : 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)); %% 基本上就是 hist = zeros(size(array));
: : if type == 'RGB' %% 建立一個跟 array 一樣大的零矩陣
: : % 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 轉 Grayscale
: : %% 應該會比較好理解
--
from cutetedy2007
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 125.230.37.176
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 4 之 4 篇):