Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
30 views

Image Processing With Python Libraries

Uploaded by

Wahyu Biantara
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Image Processing With Python Libraries

Uploaded by

Wahyu Biantara
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Academic Journal of Nawroz University (AJNU), Vol.12, No.

2, 2023
This is an open access article distributed under the Creative Commons Attribution License
Copyright ©2017. e-ISSN: 2520-789X
https://doi.org/10.25007/ajnu.v12n2a1754

Image Processing with Python Libraries


Renas Rajab Asaad1, Rasan Ismael Ali2, Zeravan Arif Ali3, Awaz Ahmad Shaban4
1Department of Computer Science, Nawroz University, Duhok, Kurdistan Region of Iraq
2,4Researchers
3Department of Information Technology Management, Duhok Polytechnic, Kurdistan Region, Iraq

ABSTRACT
Today, computer vision is considered one of the most important sub-fields of artificial intelligence, due to
the variety of its applications and capabilities to transfer the human ability to understand and describe a
scene or image to the computer, so that it becomes able to recognize objects, shapes, colors, behavior and
other capabilities of understanding the image. Image processing is one of the branches of computer science,
and it is a way to perform some operations on an image in order to obtain an improved model for this
image or extract some useful information from it. Often the data that is collected is primary data, meaning
that it is not suitable for direct use in applications, so its need to analyze or pre-process it and then use it.
For example: to build a data set that has been used in a model that classifies images as to whether they
contain a house or not, depending on an image as input for this program. Our first step will be to collect
hundreds of house images, but the problem is that these images will not be of the same dimensions, for
example, so it’s to Change its dimensions, i.e., processing it in advance before submitting it to the model.
The above is just one of the many reasons why image processing is important for any computer vision
application
Keywords: Python, OpenCV, Computer Vision, Image Processing.

1. Introduction processing for translating and obtaining information is


An open-source library developed by Intel and based on crucial for businesses. Data scientists usually preprocess
the C++ programming language. This library is the most the images before feeding it to machine learning models
widely used in image processing and computer vision. to achieve desired results. Consequently, it is paramount
This library is rich in methods and functions that to understand the capabilities of various image
facilitate the operations of dealing with and processing processing libraries to streamline their workflows.
images, where it can read images and perform many Python is a widely-used programming language for
operations on them, such as converting color images to machine learning, deep learning, and many other fields.
gray scale images, cropped images, changing image Suppose you want to make an image recognition and
dimensions resizing, and image analysis such as prediction model. Then it’s obvious that you have do
obtaining histograms and many other operations will many things before making a model, like converting to
reviewing some of them in this article. grayscale, preprocessing of image etc. Thus, you have to
Image classification is a branch of computer science that know which python image modules fit for you. In this
studies how to build algorithms that automatically label entire tutorial, you will know the best image processing
images. For example, you can use image processing to library in python [2].
automatically label your company’s logo as a car logo,
flower logo, etc. In this post, we’ll explore 15 Python 2. Computer Vision
Packages for Image Processing [1]. It can be abbreviated as the process that takes place in
A huge amount of the data collected today is made up of our brains to understand images. It is based on
images and videos. That is why effective image classification, identification, or other algorithms, so that

410
Academic Journal of Nawroz University (AJNU), Vol.12, No.2, 2023

the output is a description of what the images contain. OpenCV


Therefore, it is used in wide fields such as recognizing One of the largest and most famous open-source libraries
faces, classifying images, or analyzing them to contribute used in computer vision operations, such as: image
to driving, and many others. In this article, it will focus processing, object detection, image segmentation, face
on the image processing process. recognition and much more.
Since in programming and algorithms, the best It is the best library in terms of execution speed. It is
programming languages that are widely used in the field written in C++ and produced by Intel. The difference is
of artificial intelligence in general and in computer vision that it reads color images as BGR images instead of RGB.
in particular are Python. Because of the libraries it This library is used a lot in image processing operations
contains to shorten the work and reach satisfactory such as color conversion, image rotation, filtering, edge
results, it will present the most important libraries in the detection and chopping [4].
Python language, which you will need to enter the field Performing the color conversion process from RGB to
of image processing and computer vision [3]. Gray using the OpenCV library known as cv2 as follows:
3. Image processing 1_ Include the OpenC library in OpenCV.
Image processing focuses on applying one or several 2_ Read the image and assign it to a variable (it must put
types of transformations to the image, for example: the path and name of the image, or its name suffices if it
removing or adding noise, contrast, rotating or changing is in the project file).
color, which are operations that take place at the pixel 3_ Show the image.
level (the smallest part of the image), and are usually a 4_ Convert the color image to gray using the conversion
stage for processing and preparing images To be inputs method cvtColor() which takes the color image and the
to other stages, such as the input of a neural network, for conversion process as its variables.
example, that eventually gives a specific output [1]. 5_ Show the image.
4. Image Processing Libraries The result as it appears in the figure (1)
Image processing is the phenomenon of manipulating an
image to extract features from it.
In today’s world of computer vision and deep learning,
different algorithms for image processing are heavily
used to carry out edge detection, recognition,
classification from a dataset of images.
Sometimes these algorithms are also applied to videos
frame by frame to extract features from them [1]. Figure 1: OpenCV Lib
4.1 Numpy 4.3 Scipy
Before starting any treatment in the field of computer An open-source scientific library that relies entirely on
vision, you must know this library well, as images or matrices of the Nampai type. It is useful in applying
video clips are represented programmatically as mathematical algorithms such as integration,
matrices, and here lies the mission of this library, as the differentiation, and Fourier transforms, in addition to
Nambay library provides a multidimensional matrix algorithms such as clustering. As for image processing,
object and a variety of procedures for quick operations it contains functions that add filters to the image, such as
on matrices, including shape manipulation and sorting, noising, smoothing, and basic operations such as color
basic statistical operations, Fourier transforms and many conversion. And cutting and rotating.
more [2]. 1_ Include partial packages from the Cybay library, misc
4.2 matplotlib containing pre-saved images for the experimentation
One of the most widely used Python libraries for creating process, ndimage image containing editing functions
analytic diagrams on data (which are essentially arrays); and filters ready for images [5].
That is, what is known as the Data Visualization process. 2_ Include a Matplot library for the process of showing
By using the Matplot library, it can display images and images.
charts that help in mathematical analysis to know some 3_ Include the nambay library to deal with arrays.
details that appear graphically more clearly [3].

411
Academic Journal of Nawroz University (AJNU), Vol.12, No.2, 2023

4_ Assigning an image to deal with it as a variable


(array). 4.5 SimpleITK
5_ Modifying the image using the diving filter “glass It is a layer of ITK(Insight segmentation and registration
effect”. The function takes the image and the degree of ToolKit), which is one of the most widely used libraries
noise as its variables, and assigns them to a new variable. in medical image processing. It is used indirectly
10<<6_View the image before and after modification. through 3D slicer or ITK_SNAP programs. The reason
The result is as shown in Figure (2): for its medical use is its high ability to purify images
without Great removal of impurities that may mean a lot
in the medical field, such as a blood clot, which helps in
the correct medical reading. It supports operations on
two-, three- and four-dimensional images (three with
time) [7].
1_Include the SimpleITK library.
Figure 2: Scipy 2_ Include the Matplotlib drawing library.
4.4 PIL (Python Image Library) 3_ A variable to specify the slide number (since it is a
Currently known as PILLOW, this library provides medical image, some images consist of several
comprehensive support for all image file formats and consecutive snapshots as if they were a short video, so
basic operations on them, such as resizing, rotating, the third dimension is for the slide number “the
creating thumbnails, and converting between file snapshot”)
formats, but support has been discontinued since 2011 4_ Bringing the image and assigning it to a transformer.
and it still maintains its popularity due to its simplicity 5_ Show the image with slide number 26 (you can try
and ease of dealing with its dependencies. Fairly another number).
powerful on image processing [6]. 6_ Use a follower to apply an image smoothing process
1_Include the partial package from the Python image that takes the image and the time step (the smaller the
library. time step, the more accurate the process becomes, but
2_ Continue to fetch the image and assign it to a variable this requires an increase in the number of iterations) and
(it must put the path and name of the image, or its name the number of iterations of the process as its variables
suffices if it is in the project file). and assigning them to a variable.
3_ Rotating the image using a function that takes the 7_ Show the filtered image.
degree of rotation and the expansion process (either The result is as shown in Figure (4):
false= specifying the dimensions of the image “not to
show parts that deviate from the dimensions of the
original image” or true= expanding the dimensions so as
not to cut anything from the image) as its variables and
assigning them to a new variable.
4_ Show the image.
The result as shown in Figure (3):

Figure 4: SimpleITK
4.6 Mahotas
It is also one of the libraries used in image processing,
and in addition to its fast performance and the ability to
add effects with simple code, the Mahotas library can
dispense with the Nambay library as a helper library for
reading images as arrays, as it reads them directly as an
array, which simplifies the code and conversions even
more [8].
Figure 3: PIL

412
Academic Journal of Nawroz University (AJNU), Vol.12, No.2, 2023

1_Include Mahotas library. 6_ Multiple attributions to two converts for the same
2_ Include the matplot graphing library. image (Raed al-Qada’s image).
3_ Read the image and assign it to a variable (it must put 7_ Determine the size of the circle (it has defined the face
the path and name of the image, or its name suffices if it within the circle)
is in the project file). 8_ The size of the window lines (starting from any line
4_ Preparing to show the picture has specify).
5_ Show the image within the previous step. 9_ The size of the window columns (starting from any
6_ Finding the number of pixels that belong to each color column has specify).
gradient in the form of a graphic representation, and this 10_ Prepare a matrix with the dimensions of the rows
is what is known as a histogram, using the function () and columns of the specified window.
fullhistogram and assigning it to a variable (matrix). 11_ Using a function to determine the edges that takes
7_ Preparing window to show the histogram. the image, the size of the window within which the
8_ Histogram drawing within the window. processing will take place, the step length when defining
9_ Show an interface containing images. the edge, the smoothing rate when defining the edge,
The result, as shown in Figure (5): and the time of the learning step (mathematically, these
coefficients are the differential equation coefficients that
work to detect edges).
12_ Preparing an interface to show the images and
placing two windows for the original image and the
modified image.
13_ Putting the modified image in the second window.
14_ Show the circle (window) in red.
15_ Show the detected edges in blue.
Figure 5: Mahotas 16_ Show coordinate axes.
The diagram in Figure (5) shows that most of the colors 17_ Show numbering on the coordinate axes.
within the image are white or close to white, and this is 18_ Putting the original photo in the first window.
what its seeing in the image that “contains many white 19_ Display the interface with pictures.
areas.” The result is as shown in Figure (6):
4.7 Scikit_image
Also called skimage, it is an open source package
designed for image processing. If you have previously
dealt with the sklearn library, using skimage is a piece of
cake for its ease of handling. Even if you are new to
Python, sk Skimage is easy to learn and use [9].
The SK library is built on the libraries Numpy,
Matplotlib and scipy and must be present when using
the skimage image.[10] Figure 6: Scikit_image
It supports a large number of image processing 4.8 TensorFlow
algorithms that include segmentation, geometry, TensorFlow is a fast, flexible, and comprehensive system
filtering, features detection, and others [9]. for building machine learning systems. It is intended for
1_Include Nambay library. use with problems that have a clear conceptual structure,
2_ Include the matplot graphing library. in particular, problems that can be expressed as a linear
3_ Include the data package (which contains some transformation of inputs (e.g., matrix factorization,
images for testing) from the SK image library. structured prediction, reinforcement learning, image
4_ Embed the submersible filter from the filters package recognition, and many others). For image classification,
from the SK image library. you can use an already pre-trained model that is
5_Include an edge selection function from the slicing available in TensorFlow for ease of use [11].
package from the SK image library.

413
Academic Journal of Nawroz University (AJNU), Vol.12, No.2, 2023

Python Image Library PIL, which will be the focus of


your launch to enter the field of computer vision.
References
[1] Lai, B. C., & McKerrow, P. J. (2001, November).
Image processing libraries. In Ausralian Conference on
Robotics & Automation.
Figure 7: TensorFlow [2] Obid o’g, A. S. J., Kamalidin o'g, A. A. M., &
4.9 Keras Kamoliddin o‘g, A. N. N. (2022). Numpy Library Capabilities.
Keras is a high-level neural networks API, written in Vectorized Calculation In Numpy Va Type Of
Python and capable of running on top of TensorFlow, Information. Eurasian Research Bulletin, 15, 132-137.
CNTK, or Theano. It was developed with a focus on [3] Barrett, P., Hunter, J., Miller, J. T., Hsu, J. C., &
enabling fast experimentation. Being able to go from idea Greenfield, P. (2005, December). matplotlib--A Portable
to result with the least possible delay is key to doing Python Plotting Package. In Astronomical data analysis
good research. Using Keras you can train your network software and systems XIV (Vol. 347, p. 91).
model from scratch at configuring it how you want.[12] [4] Culjak, I., Abram, D., Pribanic, T., Dzapo, H., &
5. Discussion Cifrek, M. (2012, May). A brief introduction to OpenCV.
In this article, its explored what are the different types of In 2012 proceedings of the 35th international convention
Python Packages for Image Processing. It’s reviewed MIPRO (pp. 1725-1730). IEEE.
some Python Packages for Image Processing that help [5] Virtanen, P., Gommers, R., Oliphant, T. E.,
automate much of the process behind images. These Haberland, M., Reddy, T., Cournapeau, D., ... & Van
Python Packages for Image Processing range from low- Mulbregt, P. (2020). SciPy 1.0: fundamental algorithms for
level implementations of popular algorithms to high- scientific computing in Python. Nature methods, 17(3), 261-
level frameworks that make image classification and 272.
processing much easier. Some packages related to this [6] Greene, A. R., Scoates, J. S., & Weis, D. (2008).
topic are fairly new or underdeveloped, but there’s no Wrangellia flood basalts in Alaska: A record of plume‐
shortage of packages that can be used in this field. It’s lithosphere interaction in a Late Triassic accreted oceanic
better to use more mature and well-known libraries plateau. Geochemistry, Geophysics, Geosystems, 9(12).
anyhow. I hope this blog will help you decide on which [7] Yaniv, Z., Lowekamp, B. C., Johnson, H. J., & Beare,
tool is best for your work. R. (2018). SimpleITK image-analysis notebooks: a
6. Conclusion collaborative environment for education and reproducible
Computer vision is one of the branches of artificial research. Journal of digital imaging, 31(3), 290-303.
intelligence that focuses on developing technologies that [8] Hellerstedt, J., Cahlík, A., Švec, M., Stetsovych, O.,
& Hennen, T. (2022). Counting molecules: Python based
help computers see and understand visual content in the
scheme for automated enumeration and categorization of
same way as humans, so the Python programming
molecules in scanning tunneling microscopy images. Software
language has been supported by libraries that are based
Impacts, 12, 100301.
on processing images and video clips and using machine
[9] Van der Walt, S., Schönberger, J. L., Nunez-Iglesias,
learning and deep learning, so that it becomes able to
J., Boulogne, F., Warner, J. D., Yager, N., ... & Yu, T. (2014).
identify and classify things as they are. In previously,
scikit-image: image processing in Python. PeerJ, 2, e453.
and each library has an angle in which it is used for all
[10] Dillon, J. V., Langmore, I., Tran, D., Brevdo, E.,
image processing operations, such as the famous OpenC
Vasudevan, S., Moore, D., ... & Saurous, R. A. (2017).
library in OpenCV, which is characterized by its speed.
Tensorflow distributions. arXiv preprint arXiv:1711.10604.
Although OpenCV is the major image-processing library [11] Asaad, Renas Rajab. (2014). An Investigation of the
that has been using in the future, having a little bit of Neuronal Dynamics Under Noisy Rate Functions. Thesis
knowledge about other image-processing libraries will (M.S.), Eastern Mediterranean University, Institute of
definitely be a good idea. All these libraries can make Graduate Studies and Research, Dept. of Computer
your workflow easier with their simpler implementation Engineering, Famagusta: North Cyprus.
for specific functions. As for disease diagnosis, there [12] Asaad, R. R., Abdurahman, S. M., & Hani, A. A.
have SimpleITK, which is characterized by its accuracy, (2017). Partial Image Encryption using RC4 Stream Cipher
and other simple libraries such as Mahotas and the
414
Academic Journal of Nawroz University (AJNU), Vol.12, No.2, 2023

Approach and Embedded in an Image. Academic Journal of Nawroz University, 6(3), 1–10.
Nawroz University, 6(3), 40–45. https://doi.org/10.25007/ajnu.v6n3a70
https://doi.org/10.25007/ajnu.v6n3a76 [23] Abdulfattah, G. M., Ahmad, M. N., & Asaad, R. R.
[13] Rajab Asaad, R., & Masoud Abdulhakim, R. (2021). (2018). A reliable binarization method for offline signature
The Concept of Data Mining and Knowledge Extraction system based on unique signer’s profile. INTERNATIONAL
Techniques. Qubahan Academic Journal, 1(2), 17–20. JOURNAL OF INNOVATIVE COMPUTING
https://doi.org/10.48161/qaj.v1n2a43 INFORMATION AND CONTROL, 14(2), 573-586.
[14] Asaad, R. R., Ahmad, H. B., & Ali, R. I. (2020). A [24] Almufti, S. M., Ahmad, H. B., Marqas, R. B., &
Review: Big Data Technologies with Hadoop Distributed Asaad, R. R. (2021). Grey wolf optimizer: Overview,
Filesystem and Implementing M/R. Academic Journal of modifications and applications. International Research
Nawroz University, 9(1), 25–33. Journal of Science, Technology, Education,and
https://doi.org/10.25007/ajnu.v9n1a530 Management, 1(1),1-1.
[15] Asaad, R. R. (2019). Güler and Linaro et al Model in [25] Asaad, R. R., Sulaiman, Z. A., & Abdulmajeed, S. S.
an Investigation of the Neuronal Dynamics using noise (2019). Proposed System for Education Augmented Reality
Comparative Study. Academic Journal of Nawroz Self English Learning. Academic Journal of Nawroz
University, 8(3), 10–16. University, 8(3), 27–32.
https://doi.org/10.25007/ajnu.v8n3a360 https://doi.org/10.25007/ajnu.v8n3a366
[16] Asaad, R. R. (2021). Penetration Testing: Wireless [26] Asaad, R. R. (2020). Implementation of a Virus with
Network Attacks Method on Kali Linux OS. Academic Treatment and Protection Methods. ICONTECH
Journal of Nawroz University, 10(1), 7–12. INTERNATIONAL JOURNAL, 4(2), 28-34.
https://doi.org/10.25007/ajnu.v10n1a998 https://doi.org/10.46291/ICONTECHvol4iss2pp28-34
[17] Almufti, S., Marqas, R., & Asaad, R. (2019). [27] Boya Marqas, R., M. Almufti, S., & Rajab Asaad, R.
Comparative study between elephant herding optimization (2022). FIREBASE EFFICIENCY IN CSV DATA
(EHO) and U-turning ant colony optimization (U-TACO) in EXCHANGE THROUGH PHP-BASED
solving symmetric traveling salesman problem WEBSITES. Academic Journal of Nawroz University, 11(3),
(STSP). Journal Of Advanced Computer Science & 410–414. https://doi.org/10.25007/ajnu.v11n3a1480
Technology, 8(2), 32. [28] Ihsan, R. R., Almufti, S. M., Ormani, B. M., Asaad,
[18] Asaad, R. R., & Abdulnabi, N. L. (2018). Using Local R. R., & Marqas, R. B. (2021). A survey on Cat Swarm
Searches Algorithms with Ant Colony Optimization for the Optimization algorithm. Asian J. Res. Comput. Sci, 10, 22-32.
Solution of TSP Problems. Academic Journal of Nawroz [29] Rajab Asaad, R., & Luqman Abdulnabi, N. (2022). A
University, 7(3), 1–6. Review on Big Data Analytics between Security and Privacy
https://doi.org/10.25007/ajnu.v7n3a193 Issue. Academic Journal of Nawroz University, 11(3), 178–
[19] Almufti, S., Asaad, R., & Salim, B. (2018). Review 184. https://doi.org/10.25007/ajnu.v11n3a1446
on elephant herding optimization algorithm performance in [30] Yahya Hussien , A., & Rajab Asaad, R. (2022).
solving optimization problems. International Journal of Review on Social Media and Digital Security. Qubahan
Engineering & Technology, 7, 6109-6114. Academic Journal, 2(2), 1–4.
[20] Asaad, R. R., & Ali, R. I. (2019). Back Propagation https://doi.org/10.48161/qaj.v2n2a119
Neural Network(BPNN) and Sigmoid Activation Function in [31] Asaad, R. R. (2022). Keras Deep Learning for Pupil
Multi-Layer Networks. Academic Journal of Nawroz Detection Method . Academic Journal of Nawroz
University, 8(4), 216–221. University, 10(4), 240–250.
https://doi.org/10.25007/ajnu.v8n4a464 https://doi.org/10.25007/ajnu.v10n4a1328
[21] Rajab Asaad, R. (2021). Review on Deep Learning [32] Asaad, R. R., & Segerey, R. I. (2018). School
and Neural Network Implementation for Emotions Management Application Using iOS. Academic Journal of
Recognition . Qubahan Academic Journal, 1(1), 1–4. Nawroz University, 7(4), 38–44.
https://doi.org/10.48161/qaj.v1n1a25 https://doi.org/10.25007/ajnu.v7n4a269
[22] Asaad, R. R., Abdulrahman, S. M., & Hani, A. A. [33] Asaad, R. R., Mustafa, R. F., & Hussien, S. I. (2020).
(2017). Advanced Encryption Standard Enhancement with Mortality Statistics and Cause of Death at Duhok City from
Output Feedback Block Mode Operation. Academic Journal of The Period (2014-2019) Using R Language Data

415
Academic Journal of Nawroz University (AJNU), Vol.12, No.2, 2023

Analytics. Academic Journal of Nawroz University, 9(3), 1–7. [39] Asaad, R. R., & Saeed, V. A. (2022). A Cyber
https://doi.org/10.25007/ajnu.v9n3a699 Security Threats, Vulnerability, Challenges and Proposed
[34] Asaad, R. R. (2021). A Study on Instruction Formats Solution. Applied Computing Journal, 2(4), 227-244.
on Computer Organization and Architecture. ICONTECH https://doi.org/10.52098/acj.202260
INTERNATIONAL JOURNAL, 5(2), 18-24. [40] Renas Rajab Asaad. (2022). Support vector machine
https://doi.org/10.46291/ICONTECHvol5iss2pp18-24 classification learning algorithm for diabetes prediction.
[35] Asaad, R. R. (2021). Virtual reality and augmented International Research Journal of Science, Technology,
reality technologies: A closer look. Virtual reality, 1(2). Education, and Management, 2(2), 26–34.
[36] Asaad, R. R. A Review: Emotion Detection and https://doi.org/10.5281/zenodo.6975670
Recognition with Implementation on Deep Learning/Neural [41] Ferinia, R., Kumar, D.L.S., Kumar, B.S. et
Network. al. Factors determining customers desire to analyse supply
[37] Asaad, R. R., Saeed, V. A., & Abdulhakim, R. M. chain management in intelligent IoT. J Comb Optim 45, 72
(2021). Smart Agent and it’s effect on Artificial Intelligence: (2023). https://doi.org/10.1007/s10878-023-01007-8
A Review Study. ICONTECH INTERNATIONAL [42] Poornima, E., Muthu, B., Agrawal, R. et al. Fog
JOURNAL, 5(4), 1-9. robotics-based intelligence transportation system using line-
[38] Asaad, R. R. A Asaad, R. R. A Review: Emotion of-sight intelligent transportation. Multimed Tools
Detection and Recognition with Implementation on Deep Appl (2023). https://doi.org/10.1007/s11042-023-15086-6
Learning/Neural Network.

416

You might also like