质量筛选后的候选: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."
- ],
- "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.",
- "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."
- ],
- "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."
+ "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 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": [
+ "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": [
+ "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.
The visible pizza has been fully replaced with a rectangular frosted cake-like object, covering the full target area. The surrounding person, table, fruit, and other objects are essentially preserved. The result is visually coherent, though the cake surface is somewhat simple and flat.
{
+ original = np.asarray(image.convert('RGB')).copy()
+ src = cv2.cvtColor(original, cv2.COLOR_RGB2BGR)
+
+ def polygon_mask(vertices):
+ result = np.zeros((h, w), dtype=np.uint8)
+ points = np.array([(int(round(x * (w - 1))), int(round(y * (h - 1))))
+ for x, y in vertices], dtype=np.int32)
+ cv2.fillPoly(result, [points], 255)
+ return result
+
+ # Include the sign's outer frame and a small background margin.
+ sign = polygon_mask([
+ (0.0000, 0.3950), (0.0338, 0.3950),
+ (0.0350, 0.3985), (0.0350, 0.4800),
+ (0.0335, 0.4820), (0.0000, 0.4820)
+ ])
+ # The slender support crosses the background vehicles and ends in rubble.
+ pole = polygon_mask([
+ (0.0140, 0.4775), (0.0221, 0.4775),
+ (0.0214, 0.6888), (0.0140, 0.6888)
+ ])
+ removal = cv2.bitwise_or(sign, pole)
+ radius = max(2, int(round(w * 0.0030)))
+ filled = cv2.inpaint(src, removal, radius, cv2.INPAINT_TELEA)
+
+ # Sample the neighboring unobstructed facade at the same vertical position.
+ # This retains actual photographic texture rather than a broad smooth fill.
+ shift = max(1, int(round(w * 0.0370)))
+ donor_indices = np.minimum(np.arange(w) + shift, w - 1)
+ donor = src[:, donor_indices].copy()
+
+ # Padding makes Poisson blending safe even where the mask meets the left edge.
+ pad = max(8, int(round(w * 0.0120)))
+ donor_pad = cv2.copyMakeBorder(donor, pad, pad, pad, pad, cv2.BORDER_REFLECT_101)
+ filled_pad = cv2.copyMakeBorder(filled, pad, pad, pad, pad, cv2.BORDER_REFLECT_101)
+ sign_pad = cv2.copyMakeBorder(sign, pad, pad, pad, pad, cv2.BORDER_CONSTANT, value=0)
+ x, y, bw, bh = cv2.boundingRect(sign_pad)
+ center = (x + bw // 2, y + bh // 2)
+ cloned_pad = cv2.seamlessClone(donor_pad, filled_pad, sign_pad, center, cv2.NORMAL_CLONE)
+ cloned = cloned_pad[pad:pad + h, pad:pad + w]
+ edited = filled.astype(np.float32)
+ edited[sign > 0] = cloned[sign > 0].astype(np.float32)
+
+ # Add restrained local high-frequency texture only to the narrow pole repair.
+ texture_shift = max(1, int(round(w * 0.0110)))
+ texture_indices = np.minimum(np.arange(w) + texture_shift, w - 1)
+ texture_sample = src[:, texture_indices].astype(np.float32)
+ sigma = max(0.5, w * 0.00055)
+ low_frequency = cv2.GaussianBlur(texture_sample, (0, 0), sigmaX=sigma, sigmaY=sigma)
+ detail = np.clip(texture_sample - low_frequency, -5.0, 5.0)
+ pole_only = (pole > 0) & (sign == 0)
+ rng = np.random.default_rng(21)
+ noise = rng.normal(0.0, 0.45, (h, w, 1)).astype(np.float32)
+ textured = edited + 0.45 * detail + noise
+ edited[pole_only] = textured[pole_only]
+
+ # Feather inward within the small safety margin; all other pixels remain exact.
+ distance = cv2.distanceTransform(removal, cv2.DIST_L2, 3)
+ feather_width = max(1.0, w * 0.0010)
+ alpha = np.clip(distance / feather_width, 0.0, 1.0)[..., None]
+ result = np.clip(np.rint(src.astype(np.float32) * (1.0 - alpha) + edited * alpha), 0, 255).astype(np.uint8)
+ result[removal == 0] = src[removal == 0]
+ result_rgb = cv2.cvtColor(result, cv2.COLOR_BGR2RGB)
+ if image.mode == 'RGBA':
+ return Image.fromarray(np.dstack((result_rgb, np.asarray(image.getchannel('A')))), 'RGBA')
+ return Image.fromarray(result_rgb, 'RGB')
The visible pizza has been fully replaced with a rectangular frosted cake-like object, covering the full target area. The surrounding person, table, fruit, and other objects are essentially preserved. The result is visually coherent, though the cake surface is somewhat simple and flat.
{
"visual_evidence": "A person is preparing food at a counter. The pizza occupies the lower-right foreground, with a browned perimeter and colorful toppings. The person's hands, utensils, fruit, clothing, and blue background are outside the intended edit.",
"target_object": "The pizza in the lower-right foreground",
"target_region": "Approximately x=0.43–0.96 and y=0.74–1.00, following the pizza's angled footprint",
@@ -3323,7 +3057,7 @@ y=7: ffffff*16 f9f9f9 c6c6c6 cbcbcb 949494 9a9a9a b9b9b9 c4c4c4 bababa bfbfbf e3
"executable_code": "def edit(image):\n import cv2\n import numpy as np\n from PIL import Image, ImageDraw, ImageFont\n \n # Convert to numpy for processing if needed, but we'll mostly use PIL Draw\n img = image.copy()\n draw = ImageDraw.Draw(img)\n \n w, h = img.size\n \n # Define colors\n maroon = (128, 0, 32) # Approximate dark maroon\n black = (0, 0, 0)\n white = (255, 255, 255)\n \n # Approximate regions based on 128x128 layout\n # Left group: 0-45, Centre group: 45-90, Right group: 90-128\n \n # --- EDIT 1: Application1 in SPIR-V Clients ---\n # The prompt says 'add a white rectangle... labelled Application1'.\n # Looking at the source, there is already a small box there. We will redraw it clearly.\n # Position: bottom right area\n app_x1, app_y1 = int(w * 0.85), int(h * 0.75)\n app_x2, app_y2 = int(w * 0.98), int(h * 0.88)\n \n # Draw white rect with black border\n draw.rectangle([app_x1, app_y1, app_x2, app_y2], fill=white, outline=black, width=1)\n \n # Label 'Application1'\n # Font size needs to be tiny for 128px width\n try:\n font_small = ImageFont.truetype(\"arial.ttf\", 6)\n font_tiny = ImageFont.truetype(\"arial.ttf\", 5)\n except:\n font_small = ImageFont.load_default()\n font_tiny = ImageFont.load_default()\n \n # Center text in box\n text = \"Application1\"\n bbox = draw.textbbox((0,0), text, font=font_tiny)\n tw, th = bbox[2]-bbox[0], bbox[3]-bbox[1]\n tx = app_x1 + (app_x2-app_x1 - tw)//2\n ty = app_y1 + (app_y1-app_y1 - th)//2\n draw.text((tx, ty), text, fill=black, font=font_tiny)\n \n # Connector from centre-left edge to 'SPIR-V Generated Library' (centre group)\n # Start: left edge of app box\n start_x, start_y = app_x1, (app_y1 + app_y2) // 2\n # End: right edge of centre group (approx x=90, y=80)\n end_x, end_y = int(w * 0.70), int(h * 0.65) \n draw.line([start_x, start_y, end_x, end_y], fill=black, width=1)\n # Add arrowhead (simple triangle)\n # Vector: end - start\n dx = end_x - start_x\n dy = end_y - start_y\n length = (dx**2 + dy**2)**0.5\n if length > 0:\n ux, uy = dx/length, dy/length\n # Arrow points\n p1 = (end_x - 4*ux + 2*uy, end_y - 4*uy - 2*ux)\n p2 = (end_x - 4*ux - 2*uy, end_y - 4*uy + 2*ux)\n draw.polygon([(end_x, end_y), p1, p2], fill=black)\n\n # --- EDIT 2: SPIR-V Library Helper in Centre Panel ---\n # Position: top-middle of centre group\n lib_x1, lib_y1 = int(w * 0.50), int(h * 0.25)\n lib_x2, lib_y2 = int(w * 0.68), int(h * 0.40)\n \n # Draw maroon rect\n draw.rectangle([lib_x1, lib_y1, lib_x2, lib_y2], fill=maroon, outline=black, width=1)\n \n # Label 'SPIR-V Library Helper' (two lines)\n text1 = \"SPIR-V Library\"\n text2 = \"Helper\"\n # Center text\n bbox1 = draw.textbbox((0,0), text1, font=font_tiny)\n bbox2 = draw.textbbox((0,0), text2, font=font_tiny)\n w1, h1 = bbox1[2]-bbox1[0], bbox1[3]-bbox1[1]\n w2, h2 = bbox2[2]-bbox2[0], bbox2[3]-bbox2[1]\n \n cx = (lib_x1 + lib_x2) // 2\n cy = (lib_y1 + lib_y2) // 2\n \n # Adjust for two lines\n total_h = h1 + h2 + 2\n start_y_text = cy - total_h // 2\n \n draw.text((cx - w1//2, start_y_text), text1, fill=white, font=font_tiny)\n draw.text((cx - w2//2, start_y_text + h1 + 2), text2, fill=white, font=font_tiny)\n \n # Arrow from bottom centre to 'SPIR-V Generated Library' (existing box below)\n # Start: bottom centre of new box\n start_x, start_y = cx, lib_y2\n # End: top of existing box (approx y=60, x=60)\n end_x, end_y = int(w * 0.58), int(h * 0.55) \n draw.line([start_x, start_y, end_x, end_y], fill=black, width=1)\n # Arrowhead\n dx = end_x - start_x\n dy = end_y - start_y\n length = (dx**2 + dy**2)**0.5\n if length > 0:\n ux, uy = dx/length, dy/length\n p1 = (end_x - 4*ux + 2*uy, end_y - 4*uy - 2*ux)\n p2 = (end_x - 4*ux - 2*uy, end_y - 4*uy + 2*ux)\n draw.polygon([(end_x, end_y), p1, p2], fill=black)\n\n # --- EDIT 3: SPIR-V Utility in SPIR-V Clients (Top) ---\n # Dashed container at top right\n cont_x1, cont_y1 = int(w * 0.78), int(h * 0.05)\n cont_x2, cont_y2 = int(w * 0.98), int(h * 0.30)\n \n # Draw dashed rectangle manually\n def draw_dashed_rect(draw, box, fill=None, outline=black, width=1, dash_length=3):\n x1, y1, x2, y2 = box\n # Top\n x = x1\n while x < x2:\n draw.line([(x, y1), (min(x+dash_length, x2), y1)], fill=outline, width=width)\n x += dash_length * 2\n # Bottom\n x = x1\n while x < x2:\n draw.line([(x, y2), (min(x+dash_length, x2), y2)], fill=outline, width=width)\n x += dash_length * 2\n # Left\n y = y1\n while y < y2:\n draw.line([(x1, y), (x1, min(y+dash_length, y2))], fill=outline, width=width)\n y += dash_length * 2\n # Right\n y = y1\n while y < y2:\n draw.line([(x2, y), (x2, min(y+dash_length, y2))], fill=outline, width=width)\n y += dash_length * 2\n\n draw_dashed_rect(draw, [cont_x1, cont_y1, cont_x2, cont_y2])\n \n # Inner maroon rectangle\n util_x1, util_y1 = cont_x1 + 2, cont_y1 + 2\n util_x2, util_y2 = cont_x2 - 2, cont_y2 - 2\n draw.rectangle([util_x1, util_y1, util_x2, util_y2], fill=maroon, outline=black, width=1)\n \n # Label 'SPIR-V Utility (ASM/DISASM)'\n text3 = \"SPIR-V Utility\"\n text4 = \"(ASM/DISASM)\"\n bbox3 = draw.textbbox((0,0), text3, font=font_tiny)\n bbox4 = draw.textbbox((0,0), text4, font=font_tiny)\n w3, h3 = bbox3[2]-bbox3[0], bbox3[3]-bbox3[1]\n w4, h4 = bbox4[2]-bbox4[0], bbox4[3]-bbox4[1]\n \n cx = (util_x1 + util_x2) // 2\n cy = (util_y1 + util_y2) // 2\n total_h = h3 + h4 + 2\n start_y_text = cy - total_h // 2\n \n draw.text((cx - w3//2, start_y_text), text3, fill=white, font=font_tiny)\n draw.text((cx - w4//2, start_y_text + h3 + 2), text4, fill=white, font=font_tiny)\n \n # Connector from mid-left edge to container's left border\n start_x, start_y = util_x1, (util_y1 + util_y2) // 2\n end_x, end_y = cont_x1, (util_y1 + util_y2) // 2 - 5 # Slightly slanted\n draw.line([start_x, start_y, end_x, end_y], fill=black, width=1)\n # Arrowhead pointing left\n dx = end_x - start_x\n dy = end_y - start_y\n length = (dx**2 + dy**2)**0.5\n if length > 0:\n ux, uy = dx/length, dy/length\n p1 = (end_x - 4*ux + 2*uy, end_y - 4*uy - 2*ux)\n p2 = (end_x - 4*ux - 2*uy, end_y - 4*uy + 2*ux)\n draw.polygon([(end_x, end_y), p1, p2], fill=black)\n\n return img",
"requires_inpaint": false
}
-```
VL + 图像:图像判分依据
The SPIR-V Library Helper box and downward arrow were added in roughly the correct place, and the top-right SPIR-V Utility container/box is partially present. However, the Utility label appears cramped/clipped, and the connector integration is rough. The requested Application1 white rectangle with black border is not properly created; it appears mostly as loose text with an arrow/connector rather than a clear bordered box. Unrelated diagram content is mostly preserved, but the added elements are visually messy and incomplete.
The SPIR-V Library Helper box and downward arrow were added in roughly the correct place, and the top-right SPIR-V Utility container/box is partially present. However, the Utility label appears cramped/clipped, and the connector integration is rough. The requested Application1 white rectangle with black border is not properly created; it appears mostly as loose text with an arrow/connector rather than a clear bordered box. Unrelated diagram content is mostly preserved, but the added elements are visually messy and incomplete.