有誰知道圖像處理器(如Photoshop或Gimp)用於選擇具有相似顏色的區域的方法的名稱?另外,任何人都可以指出一些鏈接來解釋這種方法(如果可能的話,用C++代碼)?近似選擇顏色區域
Q
近似選擇顏色區域
1
A
回答
1
如果您有興趣,這可能是一個檢查顏色是否與另一個顏色相似的示例。 它也使用寬容作爲來自gimp和paint.net的魔杖。
然而,這個例子比較了價值的差異,而不是顏色或亮度的差異。
/*\ function to check if the color at this position is similar to the one you chose
|* Parameters:
|* int color - the value of the color of choice
|* int x - position x of the pixel
|* int y - position y of the pixel
|* float tolerance - how much this pixels color can differ to still be considered similar
\*/
bool isSimilar(int color, int x, int y, float tolerance)
{
// calculate difference between your color and the max value color can have
int diffMaxColor = 0xFFFFFF - color;
// set the minimum difference between your color and the minimum value of color
int diffMinColor = color;
// pseudo function to get color (could return 'colorMap[y * width + x];')
int chkColor = getColor(x, y);
// now checking whether or not the color of the pixel is in the range between max and min with tolerance
if(chkColor > (color + (diffMaxColor * tolerance)) || chkColor < ((1 - tolerance) * diffMinColor))
{
// the color is outside our tolerated range
return false;
}
// the color is inside our tolerated range
return true;
}
+0
感謝代碼示例。我只有一個問題:如果我有三種顏色成分(紅色,綠色,藍色),我如何評估第一個參數(int color)的值? –
+0
現在我明白你的意思了。參數int color只是您想要與當前像素進行比較的顏色。用魔杖這個參數等於你點擊的第一個像素的顏色。 –
相關問題
- 1. itextsharp顏色選擇器的區域
- 2. RGB顏色相近的近似算法
- 3. jvectormap區域顏色
- 4. PHP - 嘗試爲漸變背景區域定義兩種顏色的中止區域,用戶可以使用顏色選擇器同時選擇兩種顏色
- 5. 類似Snapchat的jquery顏色選擇器
- 6. PrimeFaces滑塊 - 顏色選定的區域
- 7. 選擇特定顏色的位圖區域
- 8. 如何在位圖中按顏色選擇區域?
- 9. jvectormap如何在選擇區域時保持當前顏色?
- 10. 相交區域顏色
- 11. 創建jvectormap區域顏色
- 12. 指定區域的顏色?
- 13. 顏色區域形狀PHP
- 14. jqplot背景顏色區域?
- 15. 顏色選擇框選擇
- 16. 選擇框選擇顏色
- 17. 選擇區域
- 18. Java圖片顏色區域區別
- 19. 在圖像中查找相似顏色的區域
- 20. 簡單的alghoritm獲取區域的顏色相似
- 21. QTableWidget選擇顏色
- 22. JRadioButton選擇顏色
- 23. UIButton選擇顏色
- 24. 顏色選擇器
- 25. UIButton選擇顏色
- 26. QCalendarWidget選擇顏色
- 27. JTree選擇顏色
- 28. 選擇最近的區別
- 29. 選擇區域OpenCV
- 30. MySQL選擇區域
它理應使用一個簡單的算法FloodFill像這裏http://www.dailyfreecode.com/code/flood-fill-algorithm-698.aspx與計算相似度作爲RGB空間兩種顏色之間的距離。 – SGrebenkin
非常感謝,這就是我所尋找的。 –