Image processing with single to multiple images

2024/10/8 0:26:40

I have an Image showing below: enter image description here

I need to crop the order using python coding. What I need is only the card. So I want to crop the border. How to do it??

This is the output I got using the code mentioned in the below comment.

enter image description here

Answer

All you need to do is slicing arrays. First supply the startY and endY coordinates, followed by the startX and endX coordinates to the slice. That’s it. Your image will be cropped!

Steps using Python and OpenCV:

1) load the image and display it on screen

# import the necessary packages 
import cv2
# load the image and show it
image = cv2.imread("cardWithBorder.jpg")
cv2.imshow("original", image)
cv2.waitKey(0)

2) Get the dimensions of the image

print image.shape

3) Cropping the image

# crop the image using array slices -- it's a NumPy array
# after all!
cropped = image[70:170, 440:540]
cv2.imshow("cropped", cropped)
cv2.waitKey(0)

4) Save the cropped image to disk, only in PNG format (the original was a JPG):

cv2.imwrite("thumbnail.png", cropped)
https://en.xdnf.cn/q/118757.html

Related Q&A

SQLAlchemy Automap not loading table

I am using SQLAlchemy version 2.0.19 (latest public release). I am trying to map existing tables as documented in https://docs.sqlalchemy.org/en/20/orm/extensions/automap.html#basic-use I created a SQL…

Create a base 12 calculator with different limits at diferent digits with python

I want o create a calculator that can add (and multiply, divide, etc) numbers in base 12 and with different limits at the different digits.Base 12 sequence: [0,1,2,3,4,5,6,7,8,9,"A","B&q…

Python Program to check if a number is armstrong or not is not working, what am I doing wrong?

n=int(input("Enter a Number: ")) x=0 y=0 z=0while(n>0):x=n%10y=x**3z=z+yn=n//10print (z) #The z here is the same value which I enter, yet it doesnt work. #If I enter 407 as n, z becomes (4…

Python(Scrapy) unpredictable mistake with import load_entry_point

I have such problem, I did nothing with Python or Scrapy, but when I started today my computer I got such error. I have found many different posts and tried some tips and advices, unfortunately, they a…

Debugging RadioButtons program in Python

from Tkinter import *class Application (Frame):def __init__(self, master):Frame.__init__(self, master)self.grid()self.create_widgets()def create_widgets(self):Label(self, text = "Select the last b…

Why am I getting an Internal Server error

My python script runs just fine on the Apache server locally set up on my computer, however, on importing the json2html library I am getting an internal server errorThe moment I comment the import stat…

Save pixel data in txt format in PIL

My program is to extract the pixel from an image and to save the pixel data in the text file for analysis. My picture is a binary image that gives only 255 and 0 sHere is the program:from PIL import Im…

ValueError: view limit minimum 0.0 is less than 1 and is an invalid Matplotlib date value

Ive been given the python script where matplotlib is used , when running the script it opens the window and display graph. its working perfectly on my laptop. But this error occurs when I upload the fi…

Python win32com Outlook Stores not iterable

Trying to list all Outllook stores (and finally all e-mails in those stores):import win32com.clientoutlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") sto…

Using a users input to search dictionary keys and print that keys matching value

I am working with tkinter, as I have my gui set up with and entry, label, and button. Im trying to search my dictionarys keys with the users input from the entry, and print the value of the key that wa…