答えて
私はsegmoiに応じて色の再マッピングを使用して、基本的なチャネル補正をしたhttp://photographypla.net/cross-processed-lightroom/
に私のスクリプトをベースd(赤と緑のチャンネルの場合)と青のチャンネルの場合は二重指数です。それらの関数はhttp://www.flong.com/texts/code/shapers_exp/から取った。
あなたがのparams sFactor1とsFactor2を変更することで、この結果で遊ぶことができます。
その後、私は全体のコントラストを下げ、いくつかのローカルヒストグラムの強調をしましたが、この部分を使わず、ハイライトのシャドウと白と黒の調整のための良い実装を探してください。
最終結果:
コード:
import cv2
import numpy as np
import math
# Define an S shape segmoid that with controlled shape. Based on http://www.flong.com/texts/code/shapers_exp/
# Function for sigmoid creation with s shape facor
def doubleExponentialSigmoid(x, a):
epsilon = 0.00001
min_param_a = 0.0 + epsilon
max_param_a = 1.0 - epsilon
a = min(max_param_a, max(min_param_a, a))
a = 1.0 - a # for sensible results
y = 0
if x <= 0.5:
y = (math.pow(2.0 * x, 1.0/a))/2.0
else:
y = 1.0 - (pow(2.0 * (1.0-x), 1.0/a))/2.0
return y
# Function for reverse sigmoid creation with reverse s shape facor
def doubleExponentialSeat(x,a):
epsilon = 0.00001
min_param_a = 0.0 + epsilon
max_param_a = 1.0 - epsilon
a = min(max_param_a, max(min_param_a, a))
y = 0
if x <= 0.5:
y = (math.pow(2.0*x, 1-a))/2.0;
else:
y = 1.0 - (math.pow(2.0*(1.0-x), 1-a))/2.0
return y
# Function for s shape function creation
def getSigmoidLut(sFactor,reverseShape=False):
rangeOfValues = np.arange(0, 1+(float(1)/float(255)), float(1)/float(255))
index = 0
sigmoidLUT = np.zeros_like(rangeOfValues)
if reverseShape:
for v in rangeOfValues:
sigmoidLUT[index] = doubleExponentialSeat(v, sFactor)
index = index + 1
else:
for v in rangeOfValues:
sigmoidLUT[index] = doubleExponentialSigmoid(v, sFactor)
index = index + 1
return sigmoidLUT
# A function to map one range to another
def RangeMapping(currentMin,currentMax,newMin,newMax):
newRange = np.zeros((256,1))
for v in range(256):
newRange[v] = (((v - currentMin) * (newMax - newMin))/(currentMax - currentMin)) + newMin
return newRange
# Function to lower contrast by a factor
def LowerContrast(intensityChannel, factor):
# Second chane the contrast by the factor
mappingLUT = RangeMapping(np.min(intensityChannel),np.max(intensityChannel),np.round(np.min(intensityChannel)*factor),np.round(np.max(intensityChannel)/factor))
newIntensity = cv2.LUT(intensityChannel,mappingLUT)
return newIntensity
# This cross processing is based on the tutorial in http://photographypla.net/cross-processed-lightroom/
# Params
sFactor1 = 0.7
sFactor2 = 0.3
lowContrastFactor = 1.05
# Read image
I = cv2.imread('im.jpg')
# Step 1: Separate to the three channels
R,G,B = cv2.split(I)
# Step 2: Map to a S curve each channel
# Get a S shaped segmoid
redChannelLUT = np.round(getSigmoidLut(sFactor1,False)*255).astype(np.uint8)
greenChannelLUT = redChannelLUT
blueChannelLUT =np.round(getSigmoidLut(sFactor2,True)*255).astype(np.uint8)
# Apply correction
redChannelCorrection = cv2.LUT(R, redChannelLUT)
greenChannelCorrection = cv2.LUT(G, greenChannelLUT)
blueChannelCorrection = cv2.LUT(B, blueChannelLUT)
# Step 3: Merge corrected channels
ICorrection = cv2.merge((redChannelCorrection,greenChannelCorrection,blueChannelCorrection))
# From here you can do whatever you want to the colors shadows highlights etc...
# Separate color and intensity
Iycr = cv2.cvtColor(ICorrection,cv2.COLOR_RGB2YCR_CB)
intensityCh,C,R = cv2.split(Iycr)
# Step 4: lower contrast
newLowerIntensityContrast = LowerContrast(intensityCh,lowContrastFactor)
# Step 5: Local contrast enhacment
clahe = cv2.createCLAHE(clipLimit=1.0, tileGridSize=(8,8))
ICorrectedShadows = clahe.apply(newLowerIntensityContrast.astype(np.uint8))
# Final step re construct image
IycrLowContrast = cv2.merge((ICorrectedShadows,C,R))
finalImage = cv2.cvtColor(IycrLowContrast,cv2.COLOR_YCrCb2RGB)
cv2.imshow('Original',I)
cv2.imshow('ColorCorrection',ICorrection)
cv2.imshow('LowContrast',newLowerIntensityContrast.astype(np.uint8))
cv2.imshow('Final',finalImage)
である。それが私のトリックでした。 Javascript –
でOpenCVのバージョンを実装しているのは本当に難しいですが、mine(2.4)は 'cv2.COLOR_YCrCb2RGB'属性を認識しません。 –
はopencv 3.0を使用しました –
- 1. 簡単な画像処理アルゴリズムは、私は次の操作を実行するための処理におけるアルゴリズムを書いた処理が
- 2. Pythonの画像処理でORマスキング操作を行うには?
- 3. 画像処理
- 4. ビットマップ画像を曲げる - PS5と同じです。アルゴリズム?コード?画像処理?
- 5. アンドロイドスマートフォンでの画像処理アルゴリズムの性能
- 6. 画像処理:SnapCodesを検出するアルゴリズム?
- 7. 画像処理のための適切なアルゴリズム
- 8. 画像処理 - スムージング
- 9. スウィフト画像処理
- 10. JPG画像処理
- 11. カメラ画像処理
- 12. Matlab画像処理
- 13. カフス画像処理
- 14. 画像処理Iphone
- 15. ウェブアプリケーション画像処理
- 16. 画像処理ライブラリ
- 17. Watir画像処理
- 18. Python ..画像処理
- 19. ニューラルネットワーク画像処理
- 20. PHP画像操作
- 21. C++画像操作
- 22. Rails画像操作
- 23. OpenCV画像処理 - 画像フィルタ
- 24. if文の処理、操作
- 25. ピクセル処理アルゴリズム
- 26. Android用画像処理ライブラリ
- 27. クライアント側の画像処理
- 28. C#3D画像処理
- 29. 画像処理 - ミュージックノートブロック検出
- 30. 画像処理:Photoshopの
なぜdownvote?私は研究しましたが、アルゴリズムを見つけることができませんでした。だからこそ私が求めているのは –
これは各ピクセルの赤、緑、青のチャンネルの強度に影響する**曲線**です。カーブに配列を使用できるようにするJSライブラリを探します。画像エディタでカーブを練習し、配列内の数値(配列あたり256スロット、色チャンネルごとに1つの配列)を再作成するか、計算に応じて値を更新するコードを作成します。 –