Skip to content

Instantly share code, notes, and snippets.

img1=cv2.imread(list(img_name)[0],1)
img2=cv2.imread(list(img_name1)[0],1)
dst = cv2.addWeighted(img1,0.7,img2,0.5,0) # نجمع المصفوفتين مع نضبط الاوزان
#dst = cv2.add(img1,img2) # نجمع المصفوفتين كما هي
img=cv2.cvtColor(dst, 2) # نغير نظام الألوان ل RGB
fig = plt.figure(figsize=(5, 5))
plt.axis('off')
plt.imshow(img)
from PIL import Image # مكتبة بايثون للصور ايضا
import os, sys # للوصول والتعامل مع الملفات في النظام والسستم
path = "/content/" # المسار الذي توجد به الصور
dirs = os.listdir( path ) # ترجع كل محتويات المسار
# فنكشن (دالة) توحيد الأحجام
def resize():
for item in dirs:
if os.path.isfile(path+item):
im = Image.open(path+item)
f, e = os.path.splitext(path+item) # تفصل اسم الملف عن امتداده
# حتى لا يحدث خطأ بالكود.jpg ملاحظة مهمة : جميع الصور لابد أن يكون أمتدادها
from google.colab import files # لرفع ملف من الجهاز
img_name1 = files.upload() # حفظ الملف المرفوع
# نرسم دائرة على الصورة
# ندخل اسم الصورة ،احداثيات ، نصف القطر، اللون
show= cv2.circle(show_img,(120, 150), 120, (221,160,221), -1)
fig = plt.figure(figsize=(5, 5))
plt.axis('off')
plt.imshow(show)
hsv_image=cv2.cvtColor(img, 40) #cv2.COLOR_BGR2HSV HSV (hue, saturation, value) هو نظام الالوان مختلف
ch_h ,ch_s ,ch_v =cv2.split(hsv_image) # http://bit.ly/2VtsiXZ نفصلها انقر الرابط للايضاح
ch_s[:,:] =ch_s[:,:]* 0.2 # نعدل القيمة للتغير اللون
new_img=cv2.merge((ch_h,ch_s,ch_v)) # نعيد جمعها من جديد
show_img=cv2.cvtColor(new_img, 55 ) #cv2.COLOR_HSV2RGB # RGB نحولها الى نظام الالوان
fig = plt.figure(figsize=(5, 5))
plt.axis('off')
plt.imshow(show_img,interpolation='gaussian') # مزيد من المعلومات حول التموية على الرابط https://matplotlib.org/3.1.3/gallery/images_contours_and_fields/interpolation_methods.htm
# حتى لا يحدث خطأ بالكود في الأخير.jpg ملاحظة مهمة : جميع الصور لابد أن يكون أمتدادها
from google.colab import files # لرفع ملف من الجهاز
img_name = files.upload() # حفظ الملف المرفوع
Saving content.jpg to content.jpg
img= list(img_name)[0] # حفظت الصورة بنوع قاموس فتم تغيير النوع الي لست واختيار القيمة الاولى فيها
img=cv2.imread(img,1) # #cv2.COLOR_BGR2BGR BGR نظام الألوان
img=cv2.cvtColor(img, 2) #cv2.COLOR_BGR2RGB تحويل ترتيب الألوان وللمزيد افتح الرابط https://docs.opencv.org/master/d8/d01/group__imgproc__color__conversions.html
import cv2 # مكتبة لمعالجة الصور والتعامل معها
import numpy as np # مكتبة للتعامل مع المصفوفات والعمليات الحسابية لها
from matplotlib import pyplot as plt # لاظهار الصور والرسومات
@Ruqyai
Ruqyai / ML.py
Last active February 15, 2020 11:31
import pandas as pd # lib for read and deal with dataset
import matplotlib.pylab as plt # lib for visualization
import numpy as np # lib for matrixes and arrays
#URL of the dataset
filename = "https:// ... "
#Use the Pandas method read_csv() to load the data from the web address.
!gcloud ai-platform predict --model housing_prices --json-instances records.json
%%writefile records.json
{"CRIM": 0.00632,"ZN": 18.0,"INDUS": 2.31,"NOX": 0.538, "RM": 6.575, "AGE": 65.2, "DIS": 4.0900, "TAX": 296.0, "PTRATIO": 15.3}
{"CRIM": 0.00332,"ZN": 0.0,"INDUS": 2.31,"NOX": 0.437, "RM": 7.7, "AGE": 40.0, "DIS": 5.0900, "TAX": 250.0, "PTRATIO": 17.3}