0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Google colaboratoryで画像にサクッとノイズを加える

Posted at
ipynb
# 画像をアップロード
from google.colab import files

uploaded_file = files.upload()
uploaded_file_name = next(iter(uploaded_file))

# 画像にノイズを加える
import cv2
import numpy as np
from skimage.util import random_noise

img = cv2.imread(uploaded_file_name)
noise_img = random_noise(img, mode='s&p',amount=0.5)
noise_img = np.array(255*noise_img, dtype = 'uint8')

# 画像を描画
%matplotlib inline
from matplotlib import pyplot as plt
plt.imshow(noise_img)
plt.show()

# 画像をダウンロード
from PIL import Image
Image.fromarray(noise_img).save('edited_image.jpg')
files.download('edited_image.jpg')
が下のようになります

参考
https://theailearner.com/tag/skimage-util-random_noise/

かわいい猫ちゃんはunsplashからとってきてます
https://unsplash.com/photos/IuJc2qh2TcA

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?