필터 지우기
필터 지우기

Read and display RGB png/jpg image

조회 수: 103 (최근 30일)
Kiruthiga Sekar
Kiruthiga Sekar 2020년 12월 2일
댓글: Image Analyst 2020년 12월 3일
Hi,
I need help in reading and displaying RGB png and jpg image. I am using the follwoing code, but imshow is displaying grayscale image only.
original = imread('C:\Users\R\Desktop\Image\image1.png');
original = im2double(original);
imshow(original)
title('Original image')
  댓글 수: 2
Ameer Hamza
Ameer Hamza 2020년 12월 2일
편집: Ameer Hamza 2020년 12월 2일
If you open 'image1.png' outside MATLAB, does it show a colored image? Can you attach this image?
Kiruthiga Sekar
Kiruthiga Sekar 2020년 12월 2일
yes

댓글을 달려면 로그인하십시오.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 12월 2일
You png file is actually an indexed image with a colormap. You can see it in color using following statements
[img, map] = imread('image.png');
imshow(img, map)
or, you convert it to rgb, you can use ind2rgb()
[img, map] = imread('image.png');
img_rgb = ind2rgb(img, map);
imshow(img_rgb)
  댓글 수: 7
Ameer Hamza
Ameer Hamza 2020년 12월 3일
How is the original defined? Is it rgb image of indexed image? Also, is noisyimage and noisyRGB same?
Image Analyst
Image Analyst 2020년 12월 3일
original must be either a gray scale image OR an RGB image. It makes absolutely no sense if original is a indexed image. You MUST convert it to an RGB image first, and then to a gray scale image after that if you want it as gray scale.
[indexedImage, map] = imread('image.png');
% Convert indexed image to RGB true color image.
rgbImage = ind2rgb(indexedImage, map);
% Add noise to the RGB true color image.
noisyRGBImage = imnoise(rgbImage, 'gaussian',0,0.01);
imshow(noisyRGBImage)
% Convert RGB true color image to a gray scale image.
grayImage = rgb2gray(rgbImage); % Do not pass in indexedImage!
% Add noise to the gray scale image.
noisyGrayImage = imnoise(grayImage, 'gaussian',0,0.01);
imshow(noisyGrayImage)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Red에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by