Remove upper and lower logos of mlj and make clean image
mkdir -p /tmp/workspace/mlj-clean && cd /tmp/workspace/mlj-clean && curl -s -o original.jpg "https://d361swluvexzqs.cloudfront.net/chats-attachments/1000110130-1786244332036-abxeuk.jpg" && python3 -c " from PIL import Image img = Image.open('original.jpg') print('Size:', img.size) "
cd /tmp/workspace/mlj-clean && python3 -c " from PIL import Image, ImageDraw import numpy as np img = Image.open('original.jpg').convert('RGB') w, h = img.size # 1080 x 1350 arr = np.array(img) # --- Inspect top region to get exact background color --- # Top logo is roughly rows 10-110, centered # Sample the cream background just outside the logo top_sample = arr[10:20, 10:50] # top-left corner cream area print('Top background sample (avg):', top_sample.mean(axis=(0,1))) bottom_sample = arr[1330:1345, 10:50] print('Bottom background sample (avg):', bottom_sample.mean(axis=(0,1))) "
cd /tmp/workspace/mlj-clean && python3 -c " from PIL import Image, ImageDraw import numpy as np img = Image.open('original.jpg').convert('RGB') w, h = img.size # 1080 x 1350 arr = np.array(img) # Let's look at exact pixel rows to find where the logo ends and social bar starts # Check columns around center for the top logo area - scan for where background returns # Sample a vertical strip at center-x for top area cx = 540 for row in range(0, 140, 5): px = arr[row, cx] print(f'Row {row}: {px}') "
cd /tmp/workspace/mlj-clean && python3 -c " from PIL import Image import numpy as np img = Image.open('original.jpg').convert('RGB') arr = np.array(img) h = img.size[1] # Check bottom rows to find where social bar starts for row in range(h-1, h-100, -5): px = arr[row, 540] print(f'Row {row}: {px}') "
cd /tmp/workspace/mlj-clean && python3 -c " from PIL import Image, ImageDraw import numpy as np img = Image.open('original.jpg').convert('RGB') w, h = img.size # 1080 x 1350 arr = np.array(img) # Top logo: rows 0-120 contain the emblem. Background is cream (~243,235,225). # We'll paint over rows 0-120 with the surrounding cream background. # The background at rows 130+ (below logo) is the same cream. # Strategy for top: sample the cream background below the logo area and fill top 120 rows # Use row 130-150 at various x positions to get a good sample of the gradient background # The background has a subtle gradient/texture - best to use inpainting by extending pixels from below # For the top: rows 0..119 -> fill with cream gradient matching the rest # Sample avg color from rows 130..160 across full width top_fill_sample = arr[130:160, :, :] top_fill_avg = top_fill_sample.mean(axis=0) # shape (1080, 3) - per-column average new_arr = arr.copy() # Fill top 120 rows with the sampled per-column average (smooth blend) for row in range(0, 120): new_arr[row, :, :] = top_fill_avg.astype(np.uint8) # Bottom: white pill bar is rows ~1295..1349 # Below row 1294, we see white/grey pixels of the social bar # The actual photo content ends around row 1290 # Fill rows 1290..1349 with photo content from just above (row 1285-1290) # Sample from row ~1280-1288 which has the photo photo_fill_sample = arr[1275:1285, :, :] photo_fill_avg = photo_fill_sample.mean(axis=0) # per-column for row in range(1285, h): new_arr[row, :, :] = photo_fill_avg.astype(np.uint8) result = Image.fromarray(new_arr) result.save('clean_output.jpg', quality=95) print('Done, saved clean_output.jpg') "
cd /tmp/workspace/mlj-clean && python3 -c " from PIL import Image, ImageDraw import numpy as np img = Image.open('original.jpg').convert('RGB') w, h = img.size # 1080 x 1350 arr = np.array(img) # APPROACH: # 1) Top logo (GoI emblem): rows 0-119 - replace with clean cream background # The top background has a warm cream gradient. We can reconstruct it by # extending the background from rows 120-200 upward (it's fairly uniform cream with subtle gradient) # 2) Bottom bar (rows 1285-1349): replace with photo continuation from just above # --- TOP REGION --- # Rows 120-200 are clean cream background. Let's use those to reconstruct top. # The gradient goes from slightly lighter at top to slightly more textured lower. # Use a simple approach: for each row in 0..119, copy from row (240-row) mirrored, # or just fill with a smooth gradient of the cream color. # Actually simplest clean approach: # Rows 0..119 - fill with the average cream color from rows 120..200 # but do it per-column to preserve any horizontal variation # Sample background rows 125..175 (clean cream, no text yet - text starts ~150) # Actually let's check what row the date text starts for row in range(130, 200, 5): print(f'Row {row} center: {arr[row, 540]}') "
cd /tmp/workspace/mlj-clean && python3 << 'EOF' from PIL import Image, ImageFilter import numpy as np img = Image.open('original.jpg').convert('RGB') w, h = img.size # 1080 x 1350 arr = np.array(img, dtype=np.float32) new_arr = arr.copy() # ============================================= # TOP REGION (rows 0-119): Remove GoI logo # Background is warm cream. Reconstruct by: # - Using rows 120-160 as reference (clean cream bg) # - Mirror/extend that cream background upward # The cream is almost uniform so a per-column average works well # ============================================= ref_top = arr[120:165, :, :] # 45 rows of clean cream top_bg = ref_top.mean(axis=0) # shape: (1080, 3) for row in range(0, 120): new_arr[row, :, :] = top_bg # ============================================= # BOTTOM REGION: Remove social media bar # The bar appears to be a white rounded pill on top of photo # Bar area: rows ~1293..1349 # Photo continues below up to ~1293 # Replace bar rows with photo content extended from just above # ============================================= # Check exact start of white bar: scan center column for jump to white bar_start = 1293 ref_bottom = arr[1270:1290, :, :] # photo rows just above bar bottom_bg = ref_bottom.mean(axis=0) # per-column average of photo for row in range(bar_start, h): new_arr[row, :, :] = bottom_bg # Convert back to uint8 result_arr = np.clip(new_arr, 0, 255).astype(np.uint8) result = Image.fromarray(result_arr) # Apply slight blur to top region to blend any artifacts # Crop the top region, blur it, paste back top_region = result.crop((0, 0, w, 120)) top_blurred = top_region.filter(ImageFilter.GaussianBlur(radius=2)) result.paste(top_blurred, (0, 0)) result.save('clean_output.jpg', quality=95) print(f'Saved clean_output.jpg ({w}x{h})') EOF
clean output
Image · JPG