质量筛选后的候选:Replace the blank white laptop screen with a colorful video editing software interface showing multiple timeline tracks and preview windows. Keep the laptop body, keyboard, surrounding couch fabric, headphones, melodica keyboard, microphone, cables, all other text, lighting, camera perspective, and overall scene unchanged.
{
"visual_evidence": [
- "A silver Dell laptop sits diagonally on patterned couch fabric.",
- "The laptop display is almost entirely blank white, with thin blue edges.",
- "The keyboard, palm rest, screen bezel, and Dell logo are visible.",
- "Headphones, a melodica, a desktop microphone, and cables surround the laptop."
+ "A compact bouquet with pink and pale flowers, dark flower centers, and green foliage sits below the center of the image.",
+ "The bouquet rests on a white tablecloth.",
+ "Folded white napkins and softly focused wine glasses occupy the background.",
+ "Open areas above, beside, and below the bouquet provide room for butterflies."
],
- "target_object": "The blank interior of the laptop screen",
- "target_region": "The tilted quadrilateral inside the screen bezel, excluding the existing blue display edges",
- "editing_intent": "Replace the blank display with a detailed, colorful video-editing interface containing two preview windows, media thumbnails, playback controls, and six timeline tracks.",
+ "target_object": "The space surrounding the bouquet",
+ "target_region": "Five small areas around the bouquet, without covering its flowers or foliage",
+ "editing_intent": "Add vibrant, detailed butterflies that appear to flutter around the bouquet, while preserving the existing table setting.",
"editing_plan": [
- "Define a perspective-aligned mask confined to the white display interior.",
- "Generate textured scenic preview imagery using gradients, layered terrain, reflections, and noise.",
- "Construct a detailed editing interface with menus, a media bin, two preview panels, colored video clips, audio waveforms, and level meters.",
- "Project the interface into the original screen perspective.",
- "Match screen illumination with subtle glare, shading, and fine noise, then feather the replacement inward at its boundary.",
- "Return the edited image with every pixel outside the display mask preserved."
+ "Place five butterflies in the open spaces around the bouquet.",
+ "Construct curved, scalloped forewings and hindwings with varied color, textured shading, dark margins, fine veins, and small markings.",
+ "Add shaded bodies, antennae, and delicate legs; vary the butterflies' angles and wing proportions.",
+ "Add restrained, soft shadows beneath the lower butterflies.",
+ "Antialias and alpha-composite the additions, keeping all pixels outside their silhouettes and shadows unchanged."
],
"preservation_constraints": [
- "Preserve the laptop bezel, Dell logo, keyboard, palm rest, stickers, and indicator lights.",
- "Preserve the surrounding couch fabric and its patterns.",
- "Preserve the headphones, melodica, microphone, cables, and all text outside the replaced screen interior.",
- "Do not change the camera perspective, image dimensions, or surrounding lighting."
+ "Do not change the bouquet, its flowers, foliage, or stems.",
+ "Preserve the existing tablecloth texture, folds, and lighting.",
+ "Do not remove or reposition the glasses, napkins, or cutlery.",
+ "Keep the original framing and background depth of field."
]
}
def edit(image):
import numpy as np
import cv2
- from PIL import Image, ImageDraw, ImageFont
+ from PIL import Image, ImageDraw
w, h = image.size
- original = np.array(image.convert('RGB'))
- rng = np.random.default_rng(731)
- U = max(800, int(round(w * 0.90)))
- V = int(round(U * 0.625))
- canvas = Image.new('RGB', (U, V), (43, 48, 58))
- d = ImageDraw.Draw(canvas)
-
- def box(x0, y0, x1, y1, fill, outline=None):
- d.rectangle((int(x0*U), int(y0*V), int(x1*U), int(y1*V)), fill=fill, outline=outline)
-
- def line(points, fill, width=1):
- d.line([(int(x*U), int(y*V)) for x, y in points], fill=fill, width=max(1, int(width*U/1200)))
-
- def text(x, y, value, color=(204, 212, 222), size=0.017):
- fs = max(8, int(V*size))
- try:
- font = ImageFont.load_default(size=fs)
- except TypeError:
- font = ImageFont.load_default()
- d.text((int(x*U), int(y*V)), value, fill=color, font=font)
-
- def landscape(pw, ph, shift=0.0):
- yy, xx = np.mgrid[0:ph, 0:pw].astype(np.float32)
- xx /= max(1, pw-1)
- yy /= max(1, ph-1)
- top = np.array([64, 106, 163], np.float32)
- bottom = np.array([238, 171, 118], np.float32)
- f = np.clip(yy/0.72, 0, 1)[..., None]
- a = top[None, None, :]*(1-f) + bottom[None, None, :]*f
- glow = np.exp(-(((xx-0.68)/0.25)**2 + ((yy-0.37)/0.31)**2))
- a += glow[..., None]*np.array([26, 18, 4], np.float32)
- sun = np.exp(-(((xx-0.68)/0.019)**2 + ((yy-0.35)/0.034)**2)*2.5)
- a = a*(1-sun[..., None]*0.78) + np.array([255, 237, 190])*sun[..., None]*0.78
- fine = rng.normal(0, 1.8, (ph, pw)).astype(np.float32)
- cloud = cv2.GaussianBlur(rng.normal(0, 1, (ph, pw)).astype(np.float32), (0, 0), max(1, pw*0.018))
- a += fine[..., None] + cloud[..., None]*34
- coords = np.linspace(0, 1, pw)
- for level, col, amp, seedcount in [(0.48, (111, 111, 137), 0.11, 19), (0.56, (69, 86, 115), 0.105, 27), (0.63, (41, 63, 84), 0.095, 31)]:
- controls = rng.uniform(-1, 1, seedcount)
- ridge = level + amp*np.interp(coords, np.linspace(0, 1, seedcount), controls)
- ridge = cv2.GaussianBlur(ridge.astype(np.float32).reshape(1, -1), (0, 0), max(1, pw*0.006)).ravel()
- mask = (yy > ridge[None, :]) & (yy < 0.69)
- terrain = np.asarray(col, np.float32)[None, None, :] + (yy-level)[..., None]*19 + fine[..., None]*1.6
- a[mask] = terrain[mask]
- water = yy >= 0.69
- depth = np.clip((yy-0.69)/0.31, 0, 1)
- lake = np.array([81, 111, 134])[None, None, :]*(1-depth[..., None]) + np.array([32, 67, 87])[None, None, :]*depth[..., None]
- reflected = np.exp(-((xx-0.68)/(0.026+depth*0.13))**2)*(1-depth*0.55)
- ripple = np.sin(yy*ph*1.35 + np.sin(xx*27)*2.2)*0.5 + np.sin(yy*ph*0.42 + xx*18)*0.5
- lake += reflected[..., None]*np.array([110, 68, 24])*(0.64+0.36*ripple[..., None])
- lake += ripple[..., None]*4 + fine[..., None]*1.1
- a[water] = lake[water]
- bank = yy > (0.955 - 0.045*np.sin(xx*5.8+0.8) + 0.012*np.sin(xx*38))
- foreground = np.array([22, 40, 42])[None, None, :] + fine[..., None]*2 + yy[..., None]*5
- a[bank] = foreground[bank]
- a += np.array([shift, shift*0.25, -shift*0.35])
- return Image.fromarray(np.clip(a, 0, 255).astype(np.uint8))
-
- # Application chrome and upper panels.
- box(0, 0, 1, 0.041, (62, 69, 82))
- box(0, 0.041, 1, 0.093, (47, 53, 65))
- text(0.014, 0.007, 'Studio Edit | Couch session - Creative cut', size=0.018)
- text(0.014, 0.056, 'File Edit Clip Sequence Markers View Window Help', size=0.017)
- text(0.807, 0.057, 'EDIT COLOR AUDIO', (129, 194, 219), 0.015)
- for i, col in enumerate([(217, 172, 78), (102, 160, 196), (116, 187, 154)]):
- d.ellipse((int((0.940+i*0.019)*U), int(0.013*V), int((0.948+i*0.019)*U), int(0.025*V)), fill=col)
- box(0.009, 0.103, 0.226, 0.564, (35, 41, 51), (78, 85, 99))
- box(0.234, 0.103, 0.588, 0.564, (31, 37, 47), (77, 86, 101))
- box(0.597, 0.103, 0.964, 0.564, (31, 37, 47), (77, 86, 101))
- box(0.01, 0.104, 0.226, 0.143, (54, 62, 74))
- box(0.235, 0.104, 0.588, 0.143, (54, 62, 74))
- box(0.598, 0.104, 0.964, 0.143, (54, 62, 74))
- text(0.02, 0.112, 'PROJECT / MEDIA', size=0.016)
- text(0.246, 0.112, 'SOURCE: Lake_01.mov', size=0.016)
- text(0.609, 0.112, 'PROGRAM: Creative cut', size=0.016)
- line([(0.245, 0.143), (0.337, 0.143)], (84, 188, 224), 2)
- line([(0.608, 0.143), (0.721, 0.143)], (84, 188, 224), 2)
- box(0.021, 0.157, 0.214, 0.185, (50, 56, 67), (76, 84, 96))
- text(0.028, 0.161, 'Search media...', (137, 151, 166), 0.015)
- scene1 = landscape(max(1, int(U*0.335)), max(1, int(V*0.305)), -3)
- scene2 = landscape(max(1, int(U*0.347)), max(1, int(V*0.305)), 7)
- canvas.paste(scene1, (int(0.244*U), int(0.155*V)))
- canvas.paste(scene2, (int(0.607*U), int(0.155*V)))
- d = ImageDraw.Draw(canvas)
- for i in range(4):
- tx = 0.021 + (i % 2)*0.101
- ty = 0.203 + (i // 2)*0.118
- thumb = (scene1 if i % 2 == 0 else scene2).resize((max(1, int(0.091*U)), max(1, int(0.078*V))), Image.Resampling.LANCZOS)
- canvas.paste(thumb, (int(tx*U), int(ty*V)))
- d = ImageDraw.Draw(canvas)
- text(tx, ty+0.081, ['Lake_01.mov', 'Sunset_02.mov', 'Wide_03.mov', 'Final_04.mov'][i], size=0.012)
- line([(0.02, 0.444), (0.215, 0.444)], (75, 84, 96))
- text(0.021, 0.453, '> Footage 4 clips', size=0.015)
- text(0.021, 0.485, '> Music 2 files', (140, 204, 165), 0.015)
- text(0.021, 0.516, '> Sequences 1 item', size=0.015)
- for x0, x1, tc in [(0.244, 0.577, '00:00:08:12'), (0.607, 0.953, '00:00:18:07')]:
- text(x0+0.004, 0.473, tc, (130, 208, 231), 0.019)
- text(x1-0.071, 0.478, 'Fit 100%', (144, 155, 170), 0.014)
- line([(x0+0.01, 0.508), (x1-0.01, 0.508)], (102, 117, 137))
- cx = (x0+x1)*0.5
- for k in [-2, -1, 1, 2]:
- px = cx+k*0.027
- line([(px, 0.529), (px, 0.545)], (187, 201, 217), 2)
- line([(px-0.004, 0.537), (px+0.004, 0.537)], (187, 201, 217), 1)
- d.polygon([(int((cx-0.005)*U), int(0.527*V)), (int((cx-0.005)*U), int(0.548*V)), (int((cx+0.008)*U), int(0.5375*V))], fill=(196, 214, 228))
- line([(cx+0.09, 0.527), (cx+0.09, 0.547)], (95, 196, 221), 2)
- # Timeline panel, ruler, track labels, and individual media segments.
- box(0.009, 0.580, 0.957, 0.955, (32, 38, 47), (83, 94, 109))
- box(0.010, 0.581, 0.956, 0.624, (55, 64, 78))
- text(0.021, 0.591, 'TIMELINE: Creative cut', size=0.018)
- text(0.297, 0.593, 'Selection | Snap ON', (161, 185, 206), 0.014)
- text(0.748, 0.590, '1080p 24 fps', (140, 198, 218), 0.016)
- box(0.018, 0.630, 0.155, 0.945, (45, 52, 63))
- box(0.161, 0.630, 0.945, 0.672, (46, 54, 66))
- for i in range(33):
- px = 0.167+i*(0.769/32)
- line([(px, 0.660 if i % 4 else 0.645), (px, 0.671)], (119, 131, 146))
- if i % 4 == 0:
- text(px+0.002, 0.634, '00:%02d' % (i*2), (167, 179, 195), 0.013)
- line([(px, 0.673), (px, 0.943)], (48, 56, 68))
- rows = [0.678, 0.723, 0.768, 0.813, 0.858, 0.903]
- names = ['V3 Titles', 'V2 Overlay', 'V1 Video', 'A1 Dialogue', 'A2 Music', 'A3 Ambience']
- for i, y in enumerate(rows):
- box(0.019, y, 0.154, y+0.040, (50, 57, 70) if i < 3 else (43, 62, 61))
- text(0.025, y+0.009, names[i], (198, 207, 218), 0.014)
- text(0.127, y+0.010, 'S M', (140, 155, 173), 0.010)
- line([(0.161, y+0.041), (0.945, y+0.041)], (72, 82, 96))
-
- def clip(x0, x1, row, col, label, audio=False, thumbnails=False):
- y0 = rows[row]+0.002
- y1 = rows[row]+0.039
- xa, xb = int(x0*U), int(x1*U)
- ya, yb = int(y0*V), int(y1*V)
- cw, ch = max(1, xb-xa), max(1, yb-ya)
- grad = np.linspace(1.08, 0.80, ch, dtype=np.float32)[:, None, None]
- patch = np.ones((ch, cw, 3), np.float32)*np.array(col, np.float32)*grad
- patch += rng.normal(0, 0.85, (ch, cw, 1))
- canvas.paste(Image.fromarray(np.clip(patch, 0, 255).astype(np.uint8)), (xa, ya))
- nonlocal d
- d = ImageDraw.Draw(canvas)
- line([(x0, y0), (x1, y0)], tuple(min(255, int(c*1.35)) for c in col))
- line([(x0, y0), (x0, y1)], (37, 44, 53))
- line([(x1, y0), (x1, y1)], (29, 35, 45))
- if audio:
- center = int((y0+0.026)*V)
- available = max(2, int(V*0.010))
- count = max(8, cw//3)
- energy = rng.uniform(0.2, 1.0, count)
- for j in range(count):
- xp = xa+int(j*cw/count)
- envelope = 0.28+0.72*abs(np.sin(j*0.22)+0.2*np.cos(j*0.61))/1.2
- amplitude = max(1, int(available*energy[j]*envelope))
- d.line((xp, center-amplitude, xp, center+amplitude), fill=(185, 229, 203), width=1)
- elif thumbnails:
- tw = max(12, int(U*0.034))
- th = max(3, int(V*0.014))
- mini = scene2.resize((tw, th), Image.Resampling.LANCZOS)
- for xp in range(xa+3, xb-tw, tw+4):
- canvas.paste(mini, (xp, int((y0+0.021)*V)))
- d = ImageDraw.Draw(canvas)
- if cw > U*0.062:
- text(x0+0.005, y0+0.002, label, (233, 238, 245), 0.011)
-
- clip(0.214, 0.405, 0, (145, 92, 173), 'Opening title')
- clip(0.648, 0.844, 0, (167, 97, 166), 'Closing title')
- clip(0.302, 0.525, 1, (65, 151, 178), 'Color overlay')
- clip(0.572, 0.786, 1, (60, 148, 180), 'Transition / B-roll')
- for a, b, label in [(0.165, 0.305, 'Lake_01'), (0.309, 0.492, 'Sunset_02'), (0.496, 0.640, 'Wide_03'), (0.644, 0.809, 'Lake_01'), (0.813, 0.944, 'Final_04')]:
- clip(a, b, 2, (70, 119, 187), label, thumbnails=True)
- clip(0.165, 0.456, 3, (53, 138, 121), 'Voice.wav', audio=True)
- clip(0.465, 0.735, 3, (54, 143, 120), 'Voice take 02', audio=True)
- clip(0.755, 0.944, 3, (53, 138, 121), 'Voice.wav', audio=True)
- clip(0.165, 0.944, 4, (84, 148, 98), 'Music - warm sunset.wav', audio=True)
- clip(0.224, 0.566, 5, (123, 143, 73), 'Lake ambience.wav', audio=True)
- clip(0.575, 0.944, 5, (126, 142, 74), 'Room tone.wav', audio=True)
- playx = 0.472
- line([(playx, 0.665), (playx, 0.946)], (250, 116, 89), 2)
- d.polygon([(int((playx-0.007)*U), int(0.637*V)), (int((playx+0.007)*U), int(0.637*V)), (int(playx*U), int(0.654*V))], fill=(251, 121, 91))
- box(0.963, 0.580, 0.994, 0.955, (35, 43, 51), (74, 84, 96))
- text(0.968, 0.593, 'dB', size=0.012)
- for k in range(22):
- yp = 0.914-k*0.012
- col = (100, 198, 117) if k < 15 else ((220, 192, 83) if k < 19 else (220, 102, 88))
- for channel in range(2):
- xx = 0.968+channel*0.010
- box(xx, yp, xx+0.006, yp+0.008, col if k < 19-channel*2 else (63, 74, 75))
- box(0, 0.966, 1, 1, (50, 57, 68))
- text(0.015, 0.974, 'Ready | 6 tracks | Sequence 01', (162, 179, 194), 0.013)
- text(0.764, 0.974, 'Render: Preview 00:01:04:00', (154, 186, 199), 0.013)
-
- # Screen-specific optical treatment: slight glare, edge shading, and sensor grain.
- panel = np.array(canvas).astype(np.float32)
- gy, gx = np.mgrid[0:V, 0:U].astype(np.float32)
- gx /= max(1, U-1)
- gy /= max(1, V-1)
- glare = 0.032 + 0.047*np.exp(-(((gx-0.18)/0.76)**2+((gy-0.12)/0.90)**2))
- panel = panel*(1-glare[..., None]) + np.array([218, 227, 242])*glare[..., None]
- edge = np.minimum.reduce([gx, 1-gx, gy, 1-gy])
- panel *= (0.95+0.05*np.clip(edge/0.023, 0, 1))[..., None]
- panel += rng.normal(0, 0.65, panel.shape)
- panel = cv2.GaussianBlur(np.clip(panel, 0, 255), (0, 0), 0.32)
-
- # Measured relative coordinates lie inside the existing blue display border.
- quad = np.float32([[0.0887*w, 0.2276*h], [0.3945*w, 0.0796*h], [0.4502*w, 0.3254*h], [0.1750*w, 0.5125*h]])
- flat = np.float32([[0, 0], [U-1, 0], [U-1, V-1], [0, V-1]])
- matrix = cv2.getPerspectiveTransform(flat, quad)
- warped = cv2.warpPerspective(panel, matrix, (w, h), flags=cv2.INTER_LINEAR, borderMode=cv2.BORDER_REPLICATE)
- coverage = cv2.warpPerspective(np.ones((V, U), np.float32), matrix, (w, h), flags=cv2.INTER_LINEAR, borderMode=cv2.BORDER_CONSTANT, borderValue=0)
- hard = np.zeros((h, w), np.uint8)
- cv2.fillConvexPoly(hard, np.round(quad).astype(np.int32), 255)
- distance = cv2.distanceTransform(hard, cv2.DIST_L2, 5)
- feather = max(0.85, w*0.00075)
- alpha = np.clip(distance/feather, 0, 1)*np.clip(coverage, 0, 1)
- alpha[hard == 0] = 0
- # Transfer only weak low-frequency illumination; retain the interface's contrast.
- source_luma = cv2.cvtColor(original, cv2.COLOR_RGB2GRAY).astype(np.float32)
- soft_luma = cv2.GaussianBlur(source_luma, (0, 0), max(1, w*0.008))
- valid = alpha > 0.99
- if np.any(valid):
- center_luma = np.median(soft_luma[valid])
- illumination = np.clip((soft_luma-center_luma)*0.035, -3, 3)
- warped += illumination[..., None]
- result = original.astype(np.float32)*(1-alpha[..., None]) + np.clip(warped, 0, 255)*alpha[..., None]
- out = np.clip(np.rint(result), 0, 255).astype(np.uint8)
- out[alpha == 0] = original[alpha == 0]
+ base = np.asarray(image.convert('RGB'), dtype=np.float32) / 255.0
+ result = base.copy()
+ rng = np.random.default_rng(37)
+ ss = 3
+ resampling = Image.Resampling
+
+ def bezier(p0, p1, p2, p3, count=28):
+ t = np.linspace(0.0, 1.0, count)[:, None]
+ return (1-t)**3*np.array(p0) + 3*(1-t)**2*t*np.array(p1) + 3*(1-t)*t*t*np.array(p2) + t**3*np.array(p3)
+
+ def butterfly(span, color, kind, left_scale, right_scale, angle):
+ unit = span * ss * 0.5
+ n = max(96, int(np.ceil(span * ss * 1.4)))
+ yy, xx = np.mgrid[0:n, 0:n].astype(np.float32)
+ X = (xx + 0.5 - n/2) / unit
+ Y = (yy + 0.5 - n/2) / unit
+ premult = np.zeros((n, n, 3), np.float32)
+ coverage = np.zeros((n, n), np.float32)
+
+ def over(rgb, alpha):
+ nonlocal premult, coverage
+ alpha = np.clip(alpha, 0, 1).astype(np.float32)
+ premult = np.asarray(rgb, np.float32) * alpha[..., None] + premult * (1-alpha[..., None])
+ coverage = alpha + coverage*(1-alpha)
+
+ def xy(p, side=1, scale=1):
+ return (float(n/2 + p[0]*side*scale*unit), float(n/2 + p[1]*unit))
+
+ def draw_curve(draw, points, fill, width, side=1, scale=1):
+ pts = bezier(*points)
+ draw.line([xy(p, side, scale) for p in pts], fill=fill, width=max(1, int(round(width))))
+
+ fore_start = (0.06, -0.13)
+ fore_curves = [
+ ((0.13,-0.43),(0.43,-0.79),(0.71,-0.91)),
+ ((0.83,-0.95),(1.02,-0.83),(1.00,-0.68)),
+ ((1.01,-0.56),(1.02,-0.46),(0.94,-0.40)),
+ ((0.99,-0.30),(0.94,-0.21),(0.88,-0.20)),
+ ((0.92,-0.10),(0.87,-0.01),(0.81,0.015)),
+ ((0.82,0.11),(0.73,0.22),(0.64,0.23)),
+ ((0.48,0.34),(0.20,0.29),(0.055,0.11)),
+ ((0.07,0.03),(0.07,-0.05),(0.06,-0.13))
+ ]
+ hind_start = (0.055, 0.08)
+ hind_curves = [
+ ((0.27,0.05),(0.59,0.06),(0.69,0.19)),
+ ((0.81,0.27),(0.80,0.39),(0.73,0.42)),
+ ((0.80,0.51),(0.68,0.64),(0.61,0.64)),
+ ((0.61,0.74),(0.47,0.82),(0.40,0.77)),
+ ((0.33,0.86),(0.19,0.83),(0.15,0.72)),
+ ((0.04,0.65),(0.035,0.30),(0.055,0.08))
+ ]
+ texture = rng.normal(0, 1, (n, n)).astype(np.float32)
+ soft_texture = cv2.GaussianBlur(texture, (0, 0), 1.4)
+ dark = np.array([0.075, 0.055, 0.042], np.float32)
+ if kind in ('blue', 'violet'):
+ dark = np.array([0.035, 0.045, 0.070], np.float32)
+
+ for hind in (True, False):
+ for side, scale in ((-1, left_scale), (1, right_scale)):
+ start = hind_start if hind else fore_start
+ curves = hind_curves if hind else fore_curves
+ points = []
+ p = start
+ for c1, c2, end in curves:
+ points.extend(bezier(p, c1, c2, end).tolist())
+ p = end
+ mask_image = Image.new('L', (n,n), 0)
+ md = ImageDraw.Draw(mask_image)
+ md.polygon([xy(p, side, scale) for p in points], fill=255)
+ mask = np.asarray(mask_image, np.float32)/255.0
+ distance = cv2.distanceTransform((mask > 0.5).astype(np.uint8), cv2.DIST_L2, 5)
+ local_x = X * side / scale
+ radial = np.sqrt((local_x-0.07)**2 + (Y+0.03)**2)
+ ridge = np.exp(-((local_x-0.49 + 0.12*Y)/0.31)**2)
+ light = 0.70 + 0.19*ridge + 0.08*np.clip(-Y, -0.5, 0.8)
+ light -= 0.15*np.exp(-(radial/0.23)**2)
+ light += 0.021*texture + 0.055*soft_texture
+ light += 0.018*np.sin(68*radial + 8*Y)
+ if hind:
+ light *= 0.89
+ if side == 1:
+ light *= 0.95
+ wing_rgb = np.asarray(color, np.float32)[None,None,:]*light[...,None]
+ if kind == 'blue':
+ iridescence = np.exp(-((local_x-0.53+0.23*Y)/0.28)**2)
+ wing_rgb[:,:,1] += 0.15*iridescence
+ wing_rgb[:,:,2] += 0.05*iridescence
+ elif kind == 'violet':
+ iridescence = np.exp(-((local_x-0.48)/0.31)**2)
+ wing_rgb[:,:,2] += 0.13*iridescence
+ wing_rgb[:,:,0] += 0.06*np.sin(radial*5.0)
+ elif kind == 'gold':
+ stripe = np.exp(-((local_x + 0.16*Y-0.72)/0.045)**2)
+ stripe += 0.55*np.exp(-((local_x + 0.22*Y-0.43)/0.035)**2)
+ wing_rgb *= (1-0.55*np.clip(stripe,0,1))[...,None]
+ border_width = unit*(0.067 if kind in ('blue','violet') else 0.052)
+ border_width *= 0.90 + 0.20*np.clip(radial,0,1)
+ border = np.clip((border_width-distance)/(unit*0.027), 0, 1)
+ dark_rgb = dark[None,None,:]*(0.90+0.07*texture[...,None])
+ wing_rgb = wing_rgb*(1-border[...,None]) + dark_rgb*border[...,None]
+
+ vein_image = Image.new('L', (n,n), 0)
+ vd = ImageDraw.Draw(vein_image)
+ if hind:
+ root = (0.06,0.12)
+ ends = [(0.69,0.28),(0.72,0.43),(0.62,0.62),(0.42,0.76),(0.20,0.70)]
+ else:
+ root = (0.07,-0.13)
+ ends = [(0.70,-0.86),(0.97,-0.63),(0.93,-0.40),(0.88,-0.20),(0.78,0.05),(0.59,0.24)]
+ for j, end in enumerate(ends):
+ if hind:
+ c1 = (0.20,0.16)
+ c2 = (end[0]*0.78,end[1]*0.73)
+ else:
+ c1 = (0.21,-0.24+0.022*j)
+ c2 = (end[0]*0.72,end[1]*0.72-0.045)
+ draw_curve(vd, (root,c1,c2,end), 235, unit*0.014, side, scale)
+ if not hind and j in (1,2,3):
+ branch_start = (0.43,-0.21+0.045*j)
+ branch_end = (end[0]*0.88,end[1]-0.08)
+ draw_curve(vd, (branch_start,(0.53,branch_start[1]-0.035),(branch_end[0]*0.9,branch_end[1]+0.035),branch_end), 135, unit*0.007, side, scale)
+ vein = np.asarray(vein_image,np.float32)/255.0
+ vein = cv2.GaussianBlur(vein,(0,0),0.35)
+ strength = 0.49 if kind in ('blue','violet') else 0.73
+ wing_rgb = wing_rgb*(1-strength*vein[...,None]) + dark[None,None,:]*(strength*vein[...,None])
+
+ spots_image = Image.new('L',(n,n),0)
+ sd = ImageDraw.Draw(spots_image)
+ if hind:
+ spot_positions = [(0.72,0.34),(0.66,0.51),(0.54,0.68),(0.38,0.74),(0.23,0.73)]
+ else:
+ spot_positions = [(0.71,-0.86),(0.87,-0.75),(0.95,-0.59),(0.91,-0.36),(0.85,-0.17),(0.75,0.055),(0.62,0.20)]
+ for j, p in enumerate(spot_positions):
+ if kind == 'blue' and j % 2:
+ continue
+ px,py = xy(p,side,scale)
+ r = unit*(0.020 if kind in ('orange','coral','gold') else 0.014)
+ sd.ellipse((px-r,py-r*0.73,px+r,py+r*0.73),fill=220)
+ spots = cv2.GaussianBlur(np.asarray(spots_image,np.float32)/255.0,(0,0),0.45)*mask
+ spot_color = np.array([0.93,0.87,0.67],np.float32)
+ if kind in ('blue','violet'):
+ spot_color = np.array([0.69,0.81,0.91],np.float32)
+ wing_rgb = wing_rgb*(1-spots[...,None]) + spot_color*spots[...,None]
+ alpha = cv2.GaussianBlur(mask,(0,0),0.42)
+ over(np.clip(wing_rgb,0,1),alpha)
+
+ appendages_image = Image.new('L',(n,n),0)
+ ad = ImageDraw.Draw(appendages_image)
+ for side in (-1,1):
+ draw_curve(ad, ((0.02,-0.30),(0.045,-0.43),(0.13,-0.51),(0.17,-0.65)), 240, unit*0.010, side)
+ px,py = xy((0.17,-0.65),side)
+ r = unit*0.014
+ ad.ellipse((px-r,py-r*1.6,px+r,py+r*1.6),fill=255)
+ for j in range(3):
+ start = (0.045,-0.11+0.075*j)
+ end = (0.16+0.024*j,0.10+0.095*j)
+ draw_curve(ad,(start,(0.11,start[1]+0.045),(end[0]-0.02,end[1]-0.03),end),175,unit*0.009,side)
+ appendages = cv2.GaussianBlur(np.asarray(appendages_image,np.float32)/255.0,(0,0),0.35)
+ over(np.array([0.12,0.105,0.085],np.float32),appendages)
+
+ def body_ellipse(cx,cy,rx,ry,tint):
+ dx = (X-cx)/rx
+ dy = (Y-cy)/ry
+ q = dx*dx+dy*dy
+ a = np.clip((1-q)*unit*min(rx,ry)+0.55,0,1)
+ surface = np.sqrt(np.clip(1-q,0,1))
+ illumination = 0.44+0.42*surface-0.13*dx
+ illumination += 0.035*texture
+ rgb = np.asarray(tint,np.float32)[None,None,:]*illumination[...,None]
+ rgb += 0.085*np.exp(-((dx+0.4)/0.27)**2)[...,None]*surface[...,None]
+ over(np.clip(rgb,0,1),a)
+
+ body_ellipse(0,0.20,0.039,0.23,[0.25,0.22,0.17])
+ body_ellipse(0,-0.095,0.060,0.13,[0.22,0.20,0.17])
+ body_ellipse(0,-0.275,0.039,0.046,[0.18,0.16,0.13])
+ segment_image = Image.new('L',(n,n),0)
+ segdraw = ImageDraw.Draw(segment_image)
+ for sy in (0.07,0.14,0.21,0.28,0.35):
+ rx = 0.033*np.sqrt(max(0.15,1-((sy-0.20)/0.23)**2))
+ segdraw.line([xy((-rx,sy)),xy((rx,sy+0.009))],fill=110,width=max(1,int(unit*0.008)))
+ segment_alpha = np.asarray(segment_image,np.float32)/255.0
+ over(np.array([0.055,0.048,0.037],np.float32),segment_alpha)
+
+ rgb = premult/np.maximum(coverage[...,None],1e-6)
+ rgba = np.dstack((np.clip(rgb,0,1),np.clip(coverage,0,1)))
+ layer = Image.fromarray(np.round(rgba*255).astype(np.uint8),'RGBA')
+ layer = layer.rotate(angle,resample=resampling.BICUBIC,expand=True)
+ target_size = (max(1,int(round(layer.width/ss))),max(1,int(round(layer.height/ss))))
+ layer = layer.resize(target_size,resampling.LANCZOS)
+ return np.asarray(layer,np.float32)/255.0
+
+ placements = [
+ (0.130,0.630,0.103,[0.98,0.47,0.075],'orange',0.87,1.00,24,0.0),
+ (0.390,0.530,0.098,[0.97,0.80,0.20],'gold',1.00,0.83,-24,0.0),
+ (0.615,0.708,0.122,[0.12,0.60,0.97],'blue',1.00,0.91,-18,0.10),
+ (0.535,0.905,0.101,[0.64,0.28,0.88],'violet',0.86,1.00,30,0.15),
+ (0.112,0.865,0.086,[0.97,0.32,0.22],'coral',1.00,0.88,-32,0.13)
+ ]
+ scale = min(w,h)
+ for px,py,size,color,kind,ls,rs,angle,shadow_opacity in placements:
+ sprite = butterfly(scale*size,color,kind,ls,rs,angle)
+ sh,sw = sprite.shape[:2]
+ x0 = int(round(px*w-sw/2))
+ y0 = int(round(py*h-sh/2))
+ xa,ya = max(0,x0),max(0,y0)
+ xb,yb = min(w,x0+sw),min(h,y0+sh)
+ if xb <= xa or yb <= ya:
+ continue
+ cut = sprite[ya-y0:yb-y0,xa-x0:xb-x0]
+ a = cut[:,:,3]
+ if shadow_opacity > 0:
+ silhouette = np.zeros((h,w),np.float32)
+ silhouette[ya:yb,xa:xb] = a
+ shift_x = scale*0.012
+ shift_y = scale*(0.031 if py<0.8 else 0.017)
+ transform = np.array([[1,0,shift_x],[0,1,shift_y]],np.float32)
+ shadow = cv2.warpAffine(silhouette,transform,(w,h),flags=cv2.INTER_LINEAR,borderMode=cv2.BORDER_CONSTANT)
+ shadow = cv2.GaussianBlur(shadow,(0,0),max(0.8,scale*0.008))
+ result *= (1-shadow_opacity*shadow[...,None])
+ result[ya:yb,xa:xb] = cut[:,:,:3]*a[...,None] + result[ya:yb,xa:xb]*(1-a[...,None])
+
+ output = Image.fromarray(np.round(np.clip(result,0,1)*255).astype(np.uint8),'RGB')
if image.mode == 'RGBA':
- return Image.fromarray(np.dstack([out, np.array(image.getchannel('A'))]), 'RGBA')
- return Image.fromarray(out, 'RGB')
质量筛选后的候选:Remove the yellow paddle held by the surfer on the right, seamlessly filling the area with the surrounding ocean wave, water foam, and surfer details where needed. Keep both surfers, surfboards, ocean, waves, lighting, colors, perspective, and all other elements unchanged.
质量筛选后的候选:Remove the rising sun from the top-center of the image, seamlessly blending the surrounding warm sunrise sky and atmospheric haze to maintain a natural savanna sunrise appearance. Preserve all zebras, acacia trees, tall golden grass, lighting, shadows, colors, composition, and the realistic photographic style completely unchanged.
质量筛选后的候选:Remove the street sign located on the left side of the image, seamlessly filling its space with the surrounding background (including the road, parked cars, and nearby trees), while keeping all other elements, including the bus, buildings, trees, lighting, and reflections, completely unchanged.