Showing posts with label PIP. Show all posts
Showing posts with label PIP. Show all posts

Tuesday, October 1, 2024

How do you display an image using PILL?

PIL(Pillow) is another library that can be used to display images. Pillow can also be installed using pip in the Terminal as shown by running the code pip install Pillow


After installing Pillow , you can display the image using python code as shown.

---------------

from PIL import Image

# open the image file

image=Image.open('Images/TheKiss.jpg')

#Display the image

image.show()

-----------

When you run this code the image gets displayed.


When you use Image.open(), you should give the path either the absolute path or the path relative to the project, in the above the relative project is given ('Images/TheKiss.jpg).

Here is an example of using the absolute path (in the file system)

-------------

PIL import Image


# Open an image file image = Image.open(r'C:\Users\hoden\PycharmProjects\exploreImage\Images
\TheKiss.jpg')

# Display the image
image.show()

-----------

You can see  the absolute path is used. The code gets run and you see the same image. 



If you omit the 'r' in front of the absolute path, you will get an Unicode error. The 'r' tells the interpreter to treat it as 'raw' text.

If you right click the image you can access the image path, both relative and absolute.



PyCharm does a pretty good job providing timely help with drop-down hints, code completion and syntax highlighting.

Jump to change color with Python:









Friday, February 16, 2024

What is Scikit-image?

 This latest Blogpost is by our valued guest author, Sriraksha V. Raghavan.

Image analysis, commonly known as computer vision, has made significant advances with the help of AI. However, there are still many challenges to overcome. The use of deep learning and neural networks in the analysis of images by AI is helping to narrow this gap. Currently, AI models are improving in areas such as object detection, image recognition, and generating images from text descriptions.

There are several coding tools and libraries available for these tasks, including OpenCV, TensorFlow, PyTorch, Keras, Caffe, MATLAB, CUDA, Microsoft’s Cognitive Toolkit (CNTK), Scikit-image, Dlib, Mahotas, and others. The choice of tool depends on your specific requirements, such as the complexity of the task and the hardware available.

Meet our guest author Sriraksha, an electrical engineer specializing in image sensors and machine vision. In her free time, she enjoys reading about human visual systems and continental philosophy, and dabbles in writing. You can reach her at Sriraksha.v.raghavan@gmail.com.



One of the popular Python libraries for image processing is scikit-image, an open-source collection of algorithms hosted on GitHub(1). Scikit-image has an advantage over other libraries because of the speed of its algorithms, which is essential for working with large amounts of data.

To get started with scikit-image, some understanding of the NumPy library would be beneficial but not mandatory. The easiest way to install scikit-image is via pip in your command line window(2).

Scikit-image stores images as NumPy ndarrays(n-dimensional), which are arrays of numbers with rows, columns, and dimensions. The dimensions represent the color planes of the image, such as red, green, blue, infrared, x-ray, etc. Scikit-image has various functions and classes for image processing, ranging from simple tasks like changing the color scale to complex ones like image segmentation, feature detection, and image restoration.

The best way to learn scikit-image is to download its pre-existing dataset using the function call ski.data.download_all() in your Python environment. This will give you some image sets that you can manipulate using different scikit-image functions and classes. You can also follow the tutorials available on the scikit-image website(3), which use the same datasets to demonstrate how scikit-image works.

Additionally, some useful forums to discuss scikit-image applications are their Zulip page(4), a community forum where people post queries and share ideas, and their GitHub page(1), where you can access their API and codebase.

1: scikit-image/scikit-image: Image processing in Python (https://en.wikipedia.org/wiki/Scikit-)
2: Installation — scikit-image (https://scikit-image.org/docs/stable/user_guide/install.html)
3: Tutorials — scikit-image (https://scikit-image.org/docs/stable/user_guide/tutorials.html)
4: scikit-image - Zulip Chat Archive (https://zulip.com/help/view-images-and-videos)

If you are new to,
 'pip [https://hodentekhelp.blogspot.com/2018/09/how-do-you-upgrade-pip.html]' 
or 
'Numpy [https://hodentekhelp.blogspot.com/2020/06/what-is-numpy.html]' 
you can find them in this blog in addition to other python items.


Tuesday, June 5, 2018

How do you install pyodbc?

pyodbc is an open source Python module that simplifies accessing ODBC databases. It implements the DB API 2.0 specs and has been filled with Python related items.

It can be installed with pip, with this simple statement:

pip install pyodbc

The following link provides the steps to install and configure pyodbc on Windows. The versions I have used are not the same ones used in the above link as I faced difficulties following the items.

I used Python 3.7 which was described in my previous post:
https://hodentekmsss.blogspot.com/2018/03/you-need-python-to-install-command-line.html

I followed this with installing Microsoft ODBC Driver from here:
https://docs.microsoft.com/en-us/sql/connect/sql-connection-libraries?view=sql-server-2017#anchor-20-drivers-relational-access

You must download the ODBC for working with Python in the above page.

Python drivers.png

Download the ones you want, herein the (x64)


MSODBC17.png

Double clicking the downloaded msi you can install Microsoft ODBC driver as shown here:


MSODBC17_1


Make sure you highlight the ODBC Driver for SQL Server before you click Next> on the screen.
I
t is successfully installed and gets enterer into the Drives' list in ODBC Data Source Administrator (x64) as shown.


MSODBC17_2


Now you install pyodbc using pip. I found the pip used for this post here in the Scripts folder:

C:\Users\Owner\AppData\Local\Programs\Python\Python37\Scripts

Open up a command screen in Windows and used the command as shown here:


installpyodbc.png

pyodbc gets installed here:

C:\Users\Owner\AppData\Local\Programs\Python\Python35\Lib\site-packages\









Wednesday, March 7, 2018

How do I install Python?

In my previous post you have seen how to download mssql-cli. Installing mssql-cli requires a Python command-line tool for managing Python packages.

In this post you will learn downloading and installing Python that will enable to use PIP.

You download Python from here:

https://www.python.org/downloads.

This site has a vast number of downloads not only for Windows but also for other platforms. For Windows 10 there are a number of them.

I installed the following:

python-3.7.0b2-webinstall




Python_00.png


Double click the dwonloaded file to begin installation.


Python_0



Python_2

You get these files into your computer:


Python_4


The PIP tool is in the Scripts directory in the above.

On a Windows 10 computer the following are installed in the All Programs


Python_6

You can get help on PIP as shown here by launching Python 3.7 from the above shortcut and when you are in the Python (>>>) use HELP:


Python_5