Python | Machine Learning | Coding | R
67.6K subscribers
1.26K photos
90 videos
156 files
913 links
Help and ads: @hussein_sheikho

Discover powerful insights with Python, Machine Learning, Coding, and Rβ€”your essential toolkit for data-driven solutions, smart alg

List of our channels:
https://t.me/addlist/8_rRW2scgfRhOTc0

https://telega.io/?r=nikapsOH
Download Telegram
πŸ’‘ Top 50 Pillow Operations for Image Processing
πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡
Please open Telegram to view this post
VIEW IN TELEGRAM
❀1
πŸ’‘ Top 50 Pillow Operations for Image Processing

I. File & Basic Operations

β€’ Open an image file.
from PIL import Image
img = Image.open("image.jpg")

β€’ Save an image.
img.save("new_image.png")

β€’ Display an image (opens in default viewer).
img.show()

β€’ Create a new blank image.
new_img = Image.new("RGB", (200, 100), "blue")

β€’ Get image format (e.g., 'JPEG').
print(img.format)

β€’ Get image dimensions as a (width, height) tuple.
width, height = img.size

β€’ Get pixel format (e.g., 'RGB', 'L' for grayscale).
print(img.mode)

β€’ Convert image mode.
grayscale_img = img.convert("L")

β€’ Get a pixel's color value at (x, y).
r, g, b = img.getpixel((10, 20))

β€’ Set a pixel's color value at (x, y).
img.putpixel((10, 20), (255, 0, 0))


II. Cropping, Resizing & Pasting

β€’ Crop a rectangular region.
box = (100, 100, 400, 400)
cropped_img = img.crop(box)

β€’ Resize an image to an exact size.
resized_img = img.resize((200, 200))

β€’ Create a thumbnail (maintains aspect ratio).
img.thumbnail((128, 128))

β€’ Paste one image onto another.
img.paste(another_img, (50, 50))


III. Rotation & Transformation

β€’ Rotate an image (counter-clockwise).
rotated_img = img.rotate(45, expand=True)

β€’ Flip an image horizontally.
flipped_img = img.transpose(Image.FLIP_LEFT_RIGHT)

β€’ Flip an image vertically.
flipped_img = img.transpose(Image.FLIP_TOP_BOTTOM)

β€’ Rotate by 90, 180, or 270 degrees.
img_90 = img.transpose(Image.ROTATE_90)

β€’ Apply an affine transformation.
transformed = img.transform(img.size, Image.AFFINE, (1, 0.5, 0, 0, 1, 0))


IV. ImageOps Module Helpers

β€’ Invert image colors.
from PIL import ImageOps
inverted_img = ImageOps.invert(img)

β€’ Flip an image horizontally (mirror).
mirrored_img = ImageOps.mirror(img)

β€’ Flip an image vertically.
flipped_v_img = ImageOps.flip(img)

β€’ Convert to grayscale.
grayscale = ImageOps.grayscale(img)

β€’ Colorize a grayscale image.
colorized = ImageOps.colorize(grayscale, black="blue", white="yellow")

β€’ Reduce the number of bits for each color channel.
posterized = ImageOps.posterize(img, 4)

β€’ Auto-adjust image contrast.
adjusted_img = ImageOps.autocontrast(img)

β€’ Equalize the image histogram.
equalized_img = ImageOps.equalize(img)

β€’ Add a border to an image.
bordered = ImageOps.expand(img, border=10, fill='black')


V. Color & Pixel Operations

β€’ Split image into individual bands (e.g., R, G, B).
r, g, b = img.split()

β€’ Merge bands back into an image.
merged_img = Image.merge("RGB", (r, g, b))

β€’ Apply a function to each pixel.
brighter_img = img.point(lambda i: i * 1.2)

β€’ Get a list of colors used in the image.
colors = img.getcolors(maxcolors=256)

β€’ Blend two images with alpha compositing.
# Both images must be in RGBA mode
blended = Image.alpha_composite(img1_rgba, img2_rgba)


VI. Filters (ImageFilter)
❀4
β€’ Apply a simple blur filter.
from PIL import ImageFilter
blurred_img = img.filter(ImageFilter.BLUR)

β€’ Apply a box blur with a given radius.
box_blur = img.filter(ImageFilter.BoxBlur(5))

β€’ Apply a Gaussian blur.
gaussian_blur = img.filter(ImageFilter.GaussianBlur(radius=2))

β€’ Sharpen the image.
sharpened = img.filter(ImageFilter.SHARPEN)

β€’ Find edges.
edges = img.filter(ImageFilter.FIND_EDGES)

β€’ Enhance edges.
edge_enhanced = img.filter(ImageFilter.EDGE_ENHANCE)

β€’ Emboss the image.
embossed = img.filter(ImageFilter.EMBOSS)

β€’ Find contours.
contours = img.filter(ImageFilter.CONTOUR)


VII. Image Enhancement (ImageEnhance)

β€’ Adjust color saturation.
from PIL import ImageEnhance
enhancer = ImageEnhance.Color(img)
vibrant_img = enhancer.enhance(2.0)

β€’ Adjust brightness.
enhancer = ImageEnhance.Brightness(img)
bright_img = enhancer.enhance(1.5)

β€’ Adjust contrast.
enhancer = ImageEnhance.Contrast(img)
contrast_img = enhancer.enhance(1.5)

β€’ Adjust sharpness.
enhancer = ImageEnhance.Sharpness(img)
sharp_img = enhancer.enhance(2.0)


VIII. Drawing (ImageDraw & ImageFont)

β€’ Draw text on an image.
from PIL import ImageDraw, ImageFont
draw = ImageDraw.Draw(img)
font = ImageFont.truetype("arial.ttf", 36)
draw.text((10, 10), "Hello", font=font, fill="red")

β€’ Draw a line.
draw.line((0, 0, 100, 200), fill="blue", width=3)

β€’ Draw a rectangle (outline).
draw.rectangle([10, 10, 90, 60], outline="green", width=2)

β€’ Draw a filled ellipse.
draw.ellipse([100, 100, 180, 150], fill="yellow")

β€’ Draw a polygon.
draw.polygon([(10,10), (20,50), (60,10)], fill="purple")


#Python #Pillow #ImageProcessing #PIL #CheatSheet

━━━━━━━━━━━━━━━
By: @CodeProgrammer ✨
❀12πŸ”₯6πŸ‘2πŸŽ‰2
Core Python Cheatsheet.pdf
173.3 KB
Python is a high-level, interpreted programming language known for its simplicity, readability, and
 versatility. It was first released in 1991 by Guido van Rossum and has since become one of the most
 popular programming languages in the world.
 Python’s syntax emphasizes readability, with code written in a clear and concise manner using whitespace and indentation to define blocks of code. It is an interpreted language, meaning that
 code is executed line-by-line rather than compiled into machine code. This makes it easy to write and test code quickly, without needing to worry about the details of low-level hardware.
 Python is a general-purpose language, meaning that it can be used for a wide variety of applications, from web development to scientific computing to artificial intelligence and machine learning. Its simplicity and ease of use make it a popular choice for beginners, while its power and flexibility make it a favorite of experienced developers.
 Python’s standard library contains a wide range of modules and packages, providing support for
 everything from basic data types and control structures to advanced data manipulation and visualization. Additionally, there are countless third-party packages available through Python’s package manager, pip, allowing developers to easily extend Python’s capabilities to suit their needs.
 Overall, Python’s combination of simplicity, power, and flexibility makes it an ideal language for a wide range of applications and skill levels.


https://t.me/CodeProgrammer ⚑️
Please open Telegram to view this post
VIEW IN TELEGRAM
❀7πŸ‘2πŸ‘Ž2
πŸ† 150 Python Clean Code Essentials

πŸ“’ Elevate your Python skills! Discover 150 essential Clean Code principles for writing readable, understandable, and maintainable code.

⚑ Tap to unlock the complete answer and gain instant insight.

━━━━━━━━━━━━━━━
By: @CodeProgrammer ✨
❀6πŸ‘2πŸ†1
πŸ† Unlock Data Analysis: 150 Tips, Practical Code

πŸ“’ Unlock data analysis mastery! Explore 150 essential tips, each with clear explanations and practical code examples to boost your skills.

⚑️ Tap to unlock the complete answer and gain instant insight.

━━━━━━━━━━━━━━━
By: @CodeProgrammer πŸ’›
Please open Telegram to view this post
VIEW IN TELEGRAM
❀4πŸ‘2πŸ‘1
This media is not supported in your browser
VIEW IN TELEGRAM
This combination is perhaps as low as we can get to explain how the Transformer works

#Transformers #LLM #AI

https://t.me/CodeProgrammer πŸ‘

πŸ”₯ Join us, friends: How I turned losses into profits in one night. See for yourself! | InsideAds
❀1
python-interview-questions.pdf
1.2 MB
100 Python Interview Questions and Answers

This book is a practical guide to mastering Python interview preparation. It contains 100 carefully curated questions with clear, concise answers designed in a quick-reference style.

#Python #PythonTips #PythonProgramming

https://t.me/CodeProgrammer
❀3
I watched trades hit 150+ pips profit in minutesβ€”but no one warns you what happens next. Is this the real strategy everyone copies? See all the shocking results on TRADE WITH LUCIFER. | InsideAds
❀4
πŸ€–πŸ§  PokeeResearch: Advancing Deep Research with AI and Web-Integrated Intelligence

πŸ—“οΈ 09 Nov 2025
πŸ“š AI News & Trends

In the modern information era, the ability to research fast, accurately and at scale has become a competitive advantage for businesses, researchers, analysts and developers. As online data expands exponentially, traditional search engines and manual research workflows are no longer sufficient to gather reliable insights efficiently. This need has fueled the rise of AI research ...

#AIResearch #DeepResearch #WebIntelligence #ArtificialIntelligence #ResearchAutomation #DataAnalysis
πŸ€–πŸ§  Pico-Banana-400K: The Breakthrough Dataset Advancing Text-Guided Image Editing

πŸ—“οΈ 09 Nov 2025
πŸ“š AI News & Trends

Text-guided image editing has rapidly evolved with powerful multimodal models capable of transforming images using simple natural-language instructions. These models can change object colors, modify lighting, add accessories, adjust backgrounds or even convert real photographs into artistic styles. However, the progress of research has been limited by one crucial bottleneck: the lack of large-scale, high-quality, ...

#TextGuidedEditing #MultimodalAI #ImageEditing #AIResearch #ComputerVision #DeepLearning
πŸ€–πŸ§  Concerto: How Joint 2D-3D Self-Supervised Learning Is Redefining Spatial Intelligence

πŸ—“οΈ 09 Nov 2025
πŸ“š AI News & Trends

The world of artificial intelligence is rapidly evolving and self-supervised learning has become a driving force behind breakthroughs in computer vision and 3D scene understanding. Traditional supervised learning relies heavily on labeled datasets which are expensive and time-consuming to produce. Self-supervised learning, on the other hand, extracts meaningful patterns without manual labels allowing models to ...

#SelfSupervisedLearning #ComputerVision #3DSceneUnderstanding #SpatialIntelligence #AIResearch #DeepLearning