Example 3 of D4.3 - Pre-processing #12
Labels
a/p metadata
documentation
Improvements or additions to documentation
good first issue
Good for newcomers
Use case
common
Name of resource
JPEG images to numpy array transformation
ID
JPEG_to_numpy_transformation
Description
Building dataset as numpy array. In machine learning, Python uses image data in the format of a NumPy array, i.e., [Height, Width, Channel] format. Therefore, the images must be transformed in this format. In this case, the images are in JPEG format and, through pillow, NumPy and OpenCV functions, the transformation is performed. The cv2 package (OpenCV) has the method imread() which is used to load the image and it also reads the given image (PIL image) in the NumPy array format. Because the images within the dataset (i.e., the NumPy arrays) must all be the same size to be used, and as a matter of efficiency and calculation power, using cv2's resize() the images are resized from 350x350 pixels into 100x100 (this dimension can be easily changed). The channel is three because the images are RGB. This method then returns a dataset containing the images in the format of NumPy arrays and their respective class labels.
Main category
Pre-processing
Other category
No response
Publication date
2023-08-05
Objective
data-transformation
Platform
Google Colab
Framework
OpenCV
Architecture
None
Approach
None
Algorithm
custom-method
Processor
cpu
OS
linux
Keyword
numpy array, data transformation, jpeg
Reference link
No response
Example
https://github.com/cozzolinoac11/wildfire_prediction/blob/main/img_to_NPY_transformation.ipynb
Input data used
Characteristics of input data
Biases and ethical aspects
No response
Output data obtained
Characteristics of output data
Performance
No response
Conditions for access and use
cc-by-4.0
Constraints
No response
The text was updated successfully, but these errors were encountered: