imshow() displays a white image for a grey image
I have computed an image with values between 0 and 255. When I use imageview(), the image is correctly displayed, in grey levels, but when I want to save this image or display it with imshow, I have a white image, or sometimes some black pixels here and there:
Whereas with imageview():
Can some one help me?
matlab imageview imshow
add a comment |
I have computed an image with values between 0 and 255. When I use imageview(), the image is correctly displayed, in grey levels, but when I want to save this image or display it with imshow, I have a white image, or sometimes some black pixels here and there:
Whereas with imageview():
Can some one help me?
matlab imageview imshow
2
i don't work with matlab but i have faced such problem once. Try to useimshow(uint8(image));
– skm
Mar 15 '14 at 19:56
My saviour! It works! Thank you
– user3314570
Mar 15 '14 at 20:00
1
if it worked, pls accept my answer :)
– skm
Mar 15 '14 at 20:05
@skm how do I accept? :)
– user3314570
Mar 16 '14 at 13:07
you have already accepted another answer...may be, juts "vote up" my answer by clicking the "up arrow" for my answer (not comment)
– skm
Mar 16 '14 at 14:44
add a comment |
I have computed an image with values between 0 and 255. When I use imageview(), the image is correctly displayed, in grey levels, but when I want to save this image or display it with imshow, I have a white image, or sometimes some black pixels here and there:
Whereas with imageview():
Can some one help me?
matlab imageview imshow
I have computed an image with values between 0 and 255. When I use imageview(), the image is correctly displayed, in grey levels, but when I want to save this image or display it with imshow, I have a white image, or sometimes some black pixels here and there:
Whereas with imageview():
Can some one help me?
matlab imageview imshow
matlab imageview imshow
asked Mar 15 '14 at 19:52
user3314570
117112
117112
2
i don't work with matlab but i have faced such problem once. Try to useimshow(uint8(image));
– skm
Mar 15 '14 at 19:56
My saviour! It works! Thank you
– user3314570
Mar 15 '14 at 20:00
1
if it worked, pls accept my answer :)
– skm
Mar 15 '14 at 20:05
@skm how do I accept? :)
– user3314570
Mar 16 '14 at 13:07
you have already accepted another answer...may be, juts "vote up" my answer by clicking the "up arrow" for my answer (not comment)
– skm
Mar 16 '14 at 14:44
add a comment |
2
i don't work with matlab but i have faced such problem once. Try to useimshow(uint8(image));
– skm
Mar 15 '14 at 19:56
My saviour! It works! Thank you
– user3314570
Mar 15 '14 at 20:00
1
if it worked, pls accept my answer :)
– skm
Mar 15 '14 at 20:05
@skm how do I accept? :)
– user3314570
Mar 16 '14 at 13:07
you have already accepted another answer...may be, juts "vote up" my answer by clicking the "up arrow" for my answer (not comment)
– skm
Mar 16 '14 at 14:44
2
2
i don't work with matlab but i have faced such problem once. Try to use
imshow(uint8(image));
– skm
Mar 15 '14 at 19:56
i don't work with matlab but i have faced such problem once. Try to use
imshow(uint8(image));
– skm
Mar 15 '14 at 19:56
My saviour! It works! Thank you
– user3314570
Mar 15 '14 at 20:00
My saviour! It works! Thank you
– user3314570
Mar 15 '14 at 20:00
1
1
if it worked, pls accept my answer :)
– skm
Mar 15 '14 at 20:05
if it worked, pls accept my answer :)
– skm
Mar 15 '14 at 20:05
@skm how do I accept? :)
– user3314570
Mar 16 '14 at 13:07
@skm how do I accept? :)
– user3314570
Mar 16 '14 at 13:07
you have already accepted another answer...may be, juts "vote up" my answer by clicking the "up arrow" for my answer (not comment)
– skm
Mar 16 '14 at 14:44
you have already accepted another answer...may be, juts "vote up" my answer by clicking the "up arrow" for my answer (not comment)
– skm
Mar 16 '14 at 14:44
add a comment |
2 Answers
2
active
oldest
votes
Matlab expects images of type double
to be in the 0..1 range and images that are uint8
in the 0..255 range. You can convert the range yourself (but change values in the process), do an explicit cast (and potentially loose precision) or instruct Matlab to use the minimum and maximum value found in the image matrix as the white and black value to scale to when visualising.
See the following example with an uint8
image present in Matlab:
im = imread('moon.tif');
figure; imshow(im);
figure; imshow(double(im));
figure; imshow(double(im), );
figure; imshow(im2double(im));
add a comment |
I think that you should use imshow(uint8(image));
on the image before displaying it.
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%2f22428938%2fimshow-displays-a-white-image-for-a-grey-image%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Matlab expects images of type double
to be in the 0..1 range and images that are uint8
in the 0..255 range. You can convert the range yourself (but change values in the process), do an explicit cast (and potentially loose precision) or instruct Matlab to use the minimum and maximum value found in the image matrix as the white and black value to scale to when visualising.
See the following example with an uint8
image present in Matlab:
im = imread('moon.tif');
figure; imshow(im);
figure; imshow(double(im));
figure; imshow(double(im), );
figure; imshow(im2double(im));
add a comment |
Matlab expects images of type double
to be in the 0..1 range and images that are uint8
in the 0..255 range. You can convert the range yourself (but change values in the process), do an explicit cast (and potentially loose precision) or instruct Matlab to use the minimum and maximum value found in the image matrix as the white and black value to scale to when visualising.
See the following example with an uint8
image present in Matlab:
im = imread('moon.tif');
figure; imshow(im);
figure; imshow(double(im));
figure; imshow(double(im), );
figure; imshow(im2double(im));
add a comment |
Matlab expects images of type double
to be in the 0..1 range and images that are uint8
in the 0..255 range. You can convert the range yourself (but change values in the process), do an explicit cast (and potentially loose precision) or instruct Matlab to use the minimum and maximum value found in the image matrix as the white and black value to scale to when visualising.
See the following example with an uint8
image present in Matlab:
im = imread('moon.tif');
figure; imshow(im);
figure; imshow(double(im));
figure; imshow(double(im), );
figure; imshow(im2double(im));
Matlab expects images of type double
to be in the 0..1 range and images that are uint8
in the 0..255 range. You can convert the range yourself (but change values in the process), do an explicit cast (and potentially loose precision) or instruct Matlab to use the minimum and maximum value found in the image matrix as the white and black value to scale to when visualising.
See the following example with an uint8
image present in Matlab:
im = imread('moon.tif');
figure; imshow(im);
figure; imshow(double(im));
figure; imshow(double(im), );
figure; imshow(im2double(im));
answered Mar 15 '14 at 22:20
Maurits
1,83932330
1,83932330
add a comment |
add a comment |
I think that you should use imshow(uint8(image));
on the image before displaying it.
add a comment |
I think that you should use imshow(uint8(image));
on the image before displaying it.
add a comment |
I think that you should use imshow(uint8(image));
on the image before displaying it.
I think that you should use imshow(uint8(image));
on the image before displaying it.
edited Mar 15 '14 at 20:07
answered Mar 15 '14 at 19:54
skm
2,60142560
2,60142560
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f22428938%2fimshow-displays-a-white-image-for-a-grey-image%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
2
i don't work with matlab but i have faced such problem once. Try to use
imshow(uint8(image));
– skm
Mar 15 '14 at 19:56
My saviour! It works! Thank you
– user3314570
Mar 15 '14 at 20:00
1
if it worked, pls accept my answer :)
– skm
Mar 15 '14 at 20:05
@skm how do I accept? :)
– user3314570
Mar 16 '14 at 13:07
you have already accepted another answer...may be, juts "vote up" my answer by clicking the "up arrow" for my answer (not comment)
– skm
Mar 16 '14 at 14:44