How to make Image data to 2-D distribution plot?
How to make Image data to 2-D distribution plot ?
I want to visualize image date to 2-dimensional distribution.
Is this possible ?
Image like MNIST : enter image description here
2D distribution like this :enter image description here
deep-learning
add a comment |
How to make Image data to 2-D distribution plot ?
I want to visualize image date to 2-dimensional distribution.
Is this possible ?
Image like MNIST : enter image description here
2D distribution like this :enter image description here
deep-learning
what is exactlyP(x)
andQ(x)
?
– M. Doosti Lakhani
Nov 17 '18 at 14:36
@M.DoostiLakhani That image is just show 2-d distribution. P(x) or Q(x) doesn't matter.I just want to plot MNIST data to 2D dist.
– Nazzzz
Nov 18 '18 at 1:05
add a comment |
How to make Image data to 2-D distribution plot ?
I want to visualize image date to 2-dimensional distribution.
Is this possible ?
Image like MNIST : enter image description here
2D distribution like this :enter image description here
deep-learning
How to make Image data to 2-D distribution plot ?
I want to visualize image date to 2-dimensional distribution.
Is this possible ?
Image like MNIST : enter image description here
2D distribution like this :enter image description here
deep-learning
deep-learning
asked Nov 17 '18 at 13:51
NazzzzNazzzz
54
54
what is exactlyP(x)
andQ(x)
?
– M. Doosti Lakhani
Nov 17 '18 at 14:36
@M.DoostiLakhani That image is just show 2-d distribution. P(x) or Q(x) doesn't matter.I just want to plot MNIST data to 2D dist.
– Nazzzz
Nov 18 '18 at 1:05
add a comment |
what is exactlyP(x)
andQ(x)
?
– M. Doosti Lakhani
Nov 17 '18 at 14:36
@M.DoostiLakhani That image is just show 2-d distribution. P(x) or Q(x) doesn't matter.I just want to plot MNIST data to 2D dist.
– Nazzzz
Nov 18 '18 at 1:05
what is exactly
P(x)
and Q(x)
?– M. Doosti Lakhani
Nov 17 '18 at 14:36
what is exactly
P(x)
and Q(x)
?– M. Doosti Lakhani
Nov 17 '18 at 14:36
@M.DoostiLakhani That image is just show 2-d distribution. P(x) or Q(x) doesn't matter.I just want to plot MNIST data to 2D dist.
– Nazzzz
Nov 18 '18 at 1:05
@M.DoostiLakhani That image is just show 2-d distribution. P(x) or Q(x) doesn't matter.I just want to plot MNIST data to 2D dist.
– Nazzzz
Nov 18 '18 at 1:05
add a comment |
1 Answer
1
active
oldest
votes
About mnist, it does not mean anything I think. Because you have one channel of binary image so you have only zero or one. So you cannot have any plot like that.
But if you have grayscale
image or colored
image, you can do this:
source image:
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('img.jpg', -1)
cv2.imshow('image',img)
color = ('b','g','r')
for channel,col in enumerate(color):
histr = cv2.calcHist([img],[channel],None,[256],[0,256])
plt.plot(histr,color = col)
plt.xlim([0,256])
plt.title('Histogram for color scale picture')
plt.show()
cv2.destroyAllWindows()
And if your image is grayscale:
# 1 channel image - grayscale
import cv2
from matplotlib import pyplot as plt
gray_img = cv2.imread('mnist.png')
cv2.imshow('image',gray_img)
hist = cv2.calcHist([gray_img],[0],None,[256],[0,256])
plt.hist(gray_img.ravel(),256,[0,256])
plt.title('Histogram for gray scale picture')
plt.show()
cv2.destroyAllWindows()
And the matplotlib
way is:
import matplotlib.image as mpimg
from matplotlib import pyplot as plt
img=mpimg.imread('img.jpg')
imgplot = plt.imshow(img)
plt.hist(img.ravel(), bins=256, fc='k', ec='k')
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53351852%2fhow-to-make-image-data-to-2-d-distribution-plot%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
About mnist, it does not mean anything I think. Because you have one channel of binary image so you have only zero or one. So you cannot have any plot like that.
But if you have grayscale
image or colored
image, you can do this:
source image:
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('img.jpg', -1)
cv2.imshow('image',img)
color = ('b','g','r')
for channel,col in enumerate(color):
histr = cv2.calcHist([img],[channel],None,[256],[0,256])
plt.plot(histr,color = col)
plt.xlim([0,256])
plt.title('Histogram for color scale picture')
plt.show()
cv2.destroyAllWindows()
And if your image is grayscale:
# 1 channel image - grayscale
import cv2
from matplotlib import pyplot as plt
gray_img = cv2.imread('mnist.png')
cv2.imshow('image',gray_img)
hist = cv2.calcHist([gray_img],[0],None,[256],[0,256])
plt.hist(gray_img.ravel(),256,[0,256])
plt.title('Histogram for gray scale picture')
plt.show()
cv2.destroyAllWindows()
And the matplotlib
way is:
import matplotlib.image as mpimg
from matplotlib import pyplot as plt
img=mpimg.imread('img.jpg')
imgplot = plt.imshow(img)
plt.hist(img.ravel(), bins=256, fc='k', ec='k')
add a comment |
About mnist, it does not mean anything I think. Because you have one channel of binary image so you have only zero or one. So you cannot have any plot like that.
But if you have grayscale
image or colored
image, you can do this:
source image:
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('img.jpg', -1)
cv2.imshow('image',img)
color = ('b','g','r')
for channel,col in enumerate(color):
histr = cv2.calcHist([img],[channel],None,[256],[0,256])
plt.plot(histr,color = col)
plt.xlim([0,256])
plt.title('Histogram for color scale picture')
plt.show()
cv2.destroyAllWindows()
And if your image is grayscale:
# 1 channel image - grayscale
import cv2
from matplotlib import pyplot as plt
gray_img = cv2.imread('mnist.png')
cv2.imshow('image',gray_img)
hist = cv2.calcHist([gray_img],[0],None,[256],[0,256])
plt.hist(gray_img.ravel(),256,[0,256])
plt.title('Histogram for gray scale picture')
plt.show()
cv2.destroyAllWindows()
And the matplotlib
way is:
import matplotlib.image as mpimg
from matplotlib import pyplot as plt
img=mpimg.imread('img.jpg')
imgplot = plt.imshow(img)
plt.hist(img.ravel(), bins=256, fc='k', ec='k')
add a comment |
About mnist, it does not mean anything I think. Because you have one channel of binary image so you have only zero or one. So you cannot have any plot like that.
But if you have grayscale
image or colored
image, you can do this:
source image:
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('img.jpg', -1)
cv2.imshow('image',img)
color = ('b','g','r')
for channel,col in enumerate(color):
histr = cv2.calcHist([img],[channel],None,[256],[0,256])
plt.plot(histr,color = col)
plt.xlim([0,256])
plt.title('Histogram for color scale picture')
plt.show()
cv2.destroyAllWindows()
And if your image is grayscale:
# 1 channel image - grayscale
import cv2
from matplotlib import pyplot as plt
gray_img = cv2.imread('mnist.png')
cv2.imshow('image',gray_img)
hist = cv2.calcHist([gray_img],[0],None,[256],[0,256])
plt.hist(gray_img.ravel(),256,[0,256])
plt.title('Histogram for gray scale picture')
plt.show()
cv2.destroyAllWindows()
And the matplotlib
way is:
import matplotlib.image as mpimg
from matplotlib import pyplot as plt
img=mpimg.imread('img.jpg')
imgplot = plt.imshow(img)
plt.hist(img.ravel(), bins=256, fc='k', ec='k')
About mnist, it does not mean anything I think. Because you have one channel of binary image so you have only zero or one. So you cannot have any plot like that.
But if you have grayscale
image or colored
image, you can do this:
source image:
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('img.jpg', -1)
cv2.imshow('image',img)
color = ('b','g','r')
for channel,col in enumerate(color):
histr = cv2.calcHist([img],[channel],None,[256],[0,256])
plt.plot(histr,color = col)
plt.xlim([0,256])
plt.title('Histogram for color scale picture')
plt.show()
cv2.destroyAllWindows()
And if your image is grayscale:
# 1 channel image - grayscale
import cv2
from matplotlib import pyplot as plt
gray_img = cv2.imread('mnist.png')
cv2.imshow('image',gray_img)
hist = cv2.calcHist([gray_img],[0],None,[256],[0,256])
plt.hist(gray_img.ravel(),256,[0,256])
plt.title('Histogram for gray scale picture')
plt.show()
cv2.destroyAllWindows()
And the matplotlib
way is:
import matplotlib.image as mpimg
from matplotlib import pyplot as plt
img=mpimg.imread('img.jpg')
imgplot = plt.imshow(img)
plt.hist(img.ravel(), bins=256, fc='k', ec='k')
answered Nov 18 '18 at 9:47
M. Doosti LakhaniM. Doosti Lakhani
334417
334417
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53351852%2fhow-to-make-image-data-to-2-d-distribution-plot%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
what is exactly
P(x)
andQ(x)
?– M. Doosti Lakhani
Nov 17 '18 at 14:36
@M.DoostiLakhani That image is just show 2-d distribution. P(x) or Q(x) doesn't matter.I just want to plot MNIST data to 2D dist.
– Nazzzz
Nov 18 '18 at 1:05