# Images preprocess करें

प्रीप्रोसेसिंग यह सुनिश्चित करती है कि आपका dataset एक मानक format में हो (जैसे, सभी images एक ही size की हों)। यह step एक model को train करने से पहले आपके dataset को consistent सुनिश्चित करने के लिए आवश्यक है।

Preprocessing आपके Train, Valid, और Test set की सभी images पर लागू होती है (इसके विपरीत [Augmentations](https://docs.roboflow.com/roboflow/roboflow-hi/datasets/dataset-versions/image-augmentation), जो केवल Train set पर लागू होती हैं)।

Roboflow platform निम्नलिखित preprocessing options प्रदान करता है:

* Auto-Orient
* Resize
* Grayscale
* Auto-Adjust Contrast
* Isolate Objects
* Static Crop
* Tile
* Modify Classes
* Filter Null
* Filter by Tag

हर option का वर्णन नीचे दिया गया है।

### Auto-Orient

Auto-orient आपकी images से EXIF data हटा देता है ताकि आप images को उसी तरह displayed देखें जैसे वे disk पर stored हैं।

EXIF data किसी दी गई image की orientation निर्धारित करता है। Applications (जैसे Mac पर Preview) इस data का उपयोग image को एक specific orientation में display करने के लिए करती हैं, भले ही disk पर उसके stored होने की orientation अलग हो। देखें [**यह**](https://news.ycombinator.com/item?id=21207411) front page Hacker News discussion कि यह कैसे चुपचाप आपके object detection models को खराब कर सकता है।

* Roboflow सुझाव देता है कि इसे default रूप से on ही रहने दें और जांचें कि inference में आपकी images आपके model को कैसे feed की जा रही हैं।
* यदि आप यह और जानना चाहते हैं कि आपको अपनी images auto-orient करनी चाहिए या नहीं, [हमारा blog देखें](https://blog.roboflow.com/exif-auto-orientation/).

### Resize

Resize आपकी images का size बदलता है और, वैकल्पिक रूप से, उन्हें desired dimensions के set तक scale करता है। Annotations को proportionally adjust किया जाता है (नीचे “fill” के मामले को छोड़कर)।

फिलहाल, हम केवल downsizing support करते हैं। हम इसके लिए कुछ guidance प्रदान करते हैं [कि आपके use case के लिए कौन सा resize option सबसे अच्छा हो सकता है](https://blog.roboflow.com/you-might-be-resizing-your-images-incorrectly/).

* **Stretch to:** अपनी images को preferred pixel-by-pixel dimension तक stretch करें। Annotations proportionally scaled होती हैं। Images square होती हैं, distorted होती हैं, लेकिन source image data का कोई हिस्सा नहीं खोता।
* **Fill (with center crop) in:** Generated image आपकी desired output dimensions का एक centered crop होती है। उदाहरण के लिए, यदि source image 2600x2080 है और resize option 640x640 पर set है, तो outputted resize source image का central 640x640 होगा। Aspect ratio maintained रहती है, लेकिन source image data खो जाता है।
* **Fit within:** Source dimension की dimensions को source image aspect ratio बनाए रखते हुए output image की dimensions के रूप में scale किया जाता है। उदाहरण के लिए, यदि source image 2600x2080 है और resize option 640x640 पर set है, तो लंबी dimension (2600) को 640 तक scale किया जाता है और दूसरी dimension (2080) को लगभग \~512 pixels तक scale किया जाता है। Image aspect ratios और original data maintained रहते हैं, लेकिन वे square नहीं होतीं।
* **Fit (reflect edges) in:** Source dimension की dimensions को source image aspect ratio बनाए रखते हुए output image की dimensions के रूप में scale किया जाता है, और जो भी नया padding बनाया जाता है वह source image का reflection होता है। उदाहरण के लिए, यदि source image 2600x2080 है और resize option 416x416 पर set है, तो लंबी dimension (2600) को 416 तक scale किया जाता है और दूसरी dimension (2080) को लगभग \~335.48 pixels तक scale किया जाता है। शेष pixel area (416-335.48, या 80.52 pixels) source image के reflected pixels होते हैं। विशेष रूप से, Roboflow default रूप से annotations को भी reflect करता है। Images square होती हैं, padded होती हैं, और aspect ratios के साथ original data भी maintained रहते हैं।
* **Fit (black edges) in:** Source dimension की dimensions को source image aspect ratio बनाए रखते हुए output image की dimensions के रूप में scale किया जाता है, और जो भी नया padding बनाया जाता है वह black area होता है। उदाहरण के लिए, यदि source image 2600x2080 है और resize option 416x416 पर set है, तो लंबी dimension (2600) को 416 तक scale किया जाता है और दूसरी dimension (2080) को लगभग \~335.48 pixels तक scale किया जाता है। शेष pixel area (416-335.48, या 80.52 pixels) black pixels होते हैं। Images square होती हैं, black padded होती हैं, और aspect ratios के साथ original data भी maintained रहते हैं।
* **Fit (white edges) in:** Source dimension की dimensions को source image aspect ratio बनाए रखते हुए output image की dimensions के रूप में scale किया जाता है, और जो भी नया padding बनाया जाता है वह white area होता है। उदाहरण के लिए, यदि source image 2600x2080 है और resize option 416x416 पर set है, तो लंबी dimension (2600) को 416 तक scale किया जाता है और दूसरी dimension (2080) को लगभग \~335.48 pixels तक scale किया जाता है। शेष pixel area (416-335.48, या 80.52 pixels) white pixels होते हैं। Images square होती हैं, white padded होती हैं, और aspect ratios के साथ original data भी maintained रहते हैं।

### Grayscale

RGB channels वाली image को single grayscale channel वाली image में बदलता है, जिससे आपकी memory बच सकती है। प्रत्येक grayscale pixel का मान संबंधित red, green और blue pixels के weighted sum के रूप में calculated होता है: Y = 0.2125 R + 0.7154 G + 0.0721 B.

ये weights CRT phosphors द्वारा उपयोग किए जाते हैं क्योंकि वे समान weights की तुलना में red, green और blue की human perception को बेहतर दर्शाते हैं। (Via [Scikit-Image](https://scikit-image.org/docs/dev/auto_examples/color_exposure/plot_rgb_to_gray.html).)

### Auto-Adjust Contrast

कम contrast वाली image को enhance करता है। हमने explore किया है [कि क्या आप contrast को preprocessing step के रूप में उपयोग करना चाहते हैं](https://blog.roboflow.com/when-to-use-contrast-as-a-preprocessing-step/).

* **Contrast Stretching**: image को rescale किया जाता है ताकि 2nd और 98th percentiles के भीतर आने वाली सभी intensities शामिल हों। [और देखें](http://homepages.inf.ed.ac.uk/rbf/HIPR2/stretch.htm).
* **Histogram Equalization**: image में “सबसे बार-बार आने वाले intensity values” को फैलाता है। Equalized image में लगभग uniform distribution होती है, जहाँ सभी colors के pixels लगभग समान रूप से represented होते हैं। [और देखें](https://en.wikipedia.org/wiki/Histogram_equalization).
* **Adaptive Equalization**: Contrast Limited Adaptive Histogram Equalization (CLAHE). Local contrast enhancement के लिए एक algorithm, जो image के अलग-अलग tile regions पर computed histograms का उपयोग करता है। इसलिए local details को image के अधिकांश हिस्से से अधिक dark या light regions में भी enhance किया जा सकता है। (Via [Scikit-Image](https://scikit-image.org/docs/dev/api/skimage.exposure.html#skimage.exposure.equalize_adapthist).)

## Advanced Preprocessing Features

### Isolate Objects

Isolate Objects transform हर bounding box को crop करके एक individual image में extract करेगा। यह step Object Detection datasets को Classification datasets में बदलता है।

उन मामलों में जहाँ dataset में कई classes समान होती हैं, दो models को sequence में उपयोग करना सामान्य है। पहला model (object detection) object को ढूँढता है और दूसरा model (classification) यह पहचानता है कि object क्या है। Isolate Objects transformation दूसरे model को train करने के लिए आवश्यक dataset बनाने में उपयोगी है।

### Static Crop

![static crop feature, और एक example output.](https://2698615118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M6S9nPJhEX9FYH6clfW%2Fuploads%2Fgit-blob-4f30e8b0a744bea04bcf0dadd480f55d4cb9a034%2FScreenshot%202025-05-20%20at%2009.44.47.png?alt=media)

### Tile

Tiling छोटे objects का पता लगाने में मदद कर सकता है (खासकर aerial imagery और microscopy जैसी स्थितियों में। Default setting 2x2 tiling है, हालांकि आप इसे अपनी आवश्यकता के अनुसार adjust कर सकते हैं। Tiling किया जाता है *पहले* preprocessing pipeline में resizing के।

![tiling tool और output का एक preview ("grid" में दर्शाया गया)।](https://2698615118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M6S9nPJhEX9FYH6clfW%2Fuploads%2Fgit-blob-7a09d308f703e2805c36bee439ee95451f05ca8b%2FScreenshot%202025-05-20%20at%2009.45.19.png?alt=media)

### Modify Classes

एक preprocessing tool जिसका उपयोग किसी dataset का नया version generate करते समय specific classes को omit करने या classes को remap (rename) करने के लिए किया जाता है। ये changes केवल आपके द्वारा generate किए गए version पर लागू होते हैं। आपके underlying dataset में कोई बदलाव नहीं किया जाएगा।

!["Apple leaf" class को omit करना।](https://2698615118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M6S9nPJhEX9FYH6clfW%2Fuploads%2Fgit-blob-37b01b8cc97b0d694bed8bf5d7a445fce3dbd8c9%2FScreenshot%202025-05-20%20at%2009.45.43.png?alt=media)

!["scratches" class को "scratch" में remap करना।](https://2698615118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M6S9nPJhEX9FYH6clfW%2Fuploads%2Fgit-blob-6c39656c789b92a25f4a7775bb027f33382c706c%2FScreenshot%202025-05-20%20at%2009.46.57.png?alt=media)

### Filter Null

Filter Null transformation users को यह required करने की अनुमति देता है कि dataset की एक share images annotated हों। null annotation के रूप में marked images, या Modify Classes tool लागू करने के बाद "unannotated" images, केवल वही प्रभावित होती हैं जब Filter Null उपयोग किया जाता है।

यह transformation उन मामलों में उपयोगी है जहाँ dataset का एक बड़ा हिस्सा desired objects को contain नहीं करता।

![Filter Null preprocessing step लागू करना।](https://2698615118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M6S9nPJhEX9FYH6clfW%2Fuploads%2Fgit-blob-438a722d13a06de4d81a8508b0f1204e3e61fc30%2FScreenshot%202025-05-20%20at%2009.47.41.png?alt=media)

{% hint style="warning" %}
सुनिश्चित करें कि आपने इस tool का उपयोग करने से पहले अपने dataset की ALL images को properly annotated किया है, appropriate images को null annotation के रूप में designated किया है, और/या कोई unnecessary classes omitted की हैं।
{% endhint %}

{% hint style="info" %}
[Missing और Null Annotations के बीच अंतर](https://blog.roboflow.com/missing-and-null-image-annotations/)

"Missing Annotations" तब होती हैं जब images annotated नहीं होतीं (images को unannotated छोड़ने से आपके trained dataset के performance में issues आएँगे, और training failed भी हो सकती है)। Null annotations केवल तब लागू की जानी चाहिए जब उस image में *कुछ भी* मौजूद न हो जिसे आप अपने model से detect करवाना चाहते हैं।
{% endhint %}

### Filter by Tag

Filter by Tag transformation users को यह filter करने की अनुमति देता है कि किस version में कौन सी images शामिल होनी चाहिए या नहीं, इस आधार पर कि कौन से [Tags](https://docs.roboflow.com/datasets/add-tags-to-images) applied हैं। यह transformation एक नए subset of data पर model train करने या training से unwanted images को exclude करने के लिए उपयोगी है।

प्रत्येक Tag के लिए तीन options उपलब्ध हैं:

* **Require:** केवल Required tags वाली images version में शामिल की जाएँगी।
* **Exclude**: Excluded tags वाली images version में शामिल नहीं की जाएँगी।
* **Allow:** Allowed tags वाली images version में शामिल की जाएँगी, Exclude और Require rules पर निर्भर करते हुए।

<figure><img src="https://2698615118-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M6S9nPJhEX9FYH6clfW%2Fuploads%2Fgit-blob-a4764e905f41d1e1b4e83aa437ce5ebdb7328219%2FScreenshot%202025-05-20%20at%2009.49.32.png?alt=media" alt=""><figcaption><p>इस उदाहरण में, resulting Version में केवल वे images होंगी जिनमें <code>do-not-include</code> tag नहीं है।</p></figcaption></figure>
