attachment
attachment

Make this picture look natural

analyse_media
Browsing Directory

~/

Browsing Directory

~/attachments/b6b00052-1d5f-475f-81e1-ebf1a2815b7d

Running Command

mkdir -p "/tmp/workspace/natural-night-photo/output" && python - <<'PY' from PIL import Image, ImageEnhance, ImageFilter import cv2, numpy as np src='/tmp/workspace/attachments/b6b00052-1d5f-475f-81e1-ebf1a2815b7d/1000121695.jpg' out='/tmp/workspace/natural-night-photo/output/natural_night_photo.jpg' img=cv2.imread(src, cv2.IMREAD_COLOR) # Mild chroma denoising only, retain authentic night detail img=cv2.fastNlMeansDenoisingColored(img, None, 3, 5, 7, 21) # Work in Lab: gently lift dark midtones and reduce overly hard contrast lab=cv2.cvtColor(img, cv2.COLOR_BGR2LAB) L,a,b=cv2.split(lab) # soft S curve with shadow lift, restrained highlights x=np.arange(256,dtype=np.float32)/255.0 y=np.where(x<0.55, 0.015 + 0.94*x + 0.11*x*(0.55-x)/0.55, 0.015 + 0.94*x) y=np.clip(y,0,1) L=cv2.LUT(L,(y*255).astype(np.uint8)) # slight neutralization of green/cyan cast in deep night sky a=cv2.addWeighted(a,0.92,np.full_like(a,128),0.08,0) b=cv2.addWeighted(b,0.96,np.full_like(b,128),0.04,0) res=cv2.cvtColor(cv2.merge((L,a,b)),cv2.COLOR_LAB2BGR) # reduce moon highlight glare with highlight compression based on luminance rgb=cv2.cvtColor(res,cv2.COLOR_BGR2RGB).astype(np.float32)/255 lum=0.2126*rgb[:,:,0]+0.7152*rgb[:,:,1]+0.0722*rgb[:,:,2] mask=np.clip((lum-.70)/.30,0,1)[...,None] rgb=rgb*(1-mask*.12) + np.minimum(rgb*1.01,1)*mask*.12 # subtle sharpening after denoise res=cv2.cvtColor((rgb*255).astype(np.uint8),cv2.COLOR_RGB2BGR) blur=cv2.GaussianBlur(res,(0,0),0.7) res=cv2.addWeighted(res,1.12,blur,-0.12,0) cv2.imwrite(out,res,[cv2.IMWRITE_JPEG_QUALITY,95]) print(out, res.shape) PY python - <<'PY' from PIL import Image p='/tmp/workspace/natural-night-photo/output/natural_night_photo.jpg' im=Image.open(p) print(im.size, im.mode) PY

Adjusted the night photo to look more natural with softer contrast, reduced color cast and noise, lifted shadow detail slightly, and restrained the moon’s glare.

natural night photo

Image · JPG

This is a shared conversation. Sign in to Orris to start your own chat.