Python Forum
How to invert pixel numbers of MNIST data set
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to invert pixel numbers of MNIST data set
#2
I suspect you've used a dataset which is similar to this one.

As far as I understand, pixel inversion is transformation when black colors become white and vice verse?! If so, the following code can help you:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data=pd.read_csv("https://raw.githubusercontent.com/sjwhitworth/golearn/master/examples/datasets/mnist_train.csv")
data.values[:, 1:] = np.abs(data.values[:, 1:] - 255)  # color inversion
x=data.values[-1, 1:]  # plot latest row in the dataset
plt.imshow(x.reshape(28, 28), cmap='gray')
plt.show()
Reply


Messages In This Thread
RE: How to invert pixel numbers of MNIST data set - by scidam - Oct-16-2019, 11:18 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Voxel to pixel graphics voicemail 3 600 Nov-19-2023, 09:45 AM
Last Post: paul18fr
  Pixel color and action Sartre 4 2,150 Apr-13-2023, 03:26 AM
Last Post: Sartre
  Dynamic pixel display jerryf 2 749 Mar-17-2023, 07:26 PM
Last Post: jerryf
  How to invert scatter plot axis Mark17 3 2,569 Sep-22-2021, 04:45 PM
Last Post: jefsummers
  Plotting Pixel Intensity Doev 0 1,751 Oct-21-2020, 10:56 PM
Last Post: Doev
  5 variants to invert dictionaries with non-unique values Drakax1 2 2,642 Aug-31-2020, 11:40 AM
Last Post: snippsat
  Invert Pillow image colours chesschaser 5 3,903 Jul-11-2020, 02:59 PM
Last Post: chesschaser
  Return draw.rectangle pixel coordinate data to .csv file CephloRhod 0 2,403 May-20-2020, 10:37 AM
Last Post: CephloRhod
  What is the best way to search for a pixel in a screenshot? TheZadok42 1 2,646 May-15-2020, 12:37 PM
Last Post: scidam
  Issue with creating an array of pixel data for PNG files in Google Colab The_Sarco 1 1,950 Apr-29-2020, 12:03 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020