please ineed help for this "Load the image ‘cameraman.tif’, find its dimensions and number of channels and display it."

39 views (last 30 days)
img = imread('cameramna.png'); % Read image
red = img(:,:,1); % Red channel
green = img(:,:,2); % Green channel
blue = img(:,:,3);
i write this code but it cannot run. help...!!
  1 Comment
Guillaume
Guillaume on 2 Apr 2019
"i write this code but it cannot run. help...!!"
If you get an error, give us the full text of the error message so we don't have to guess what the problem can be.
First problem with the code you show is that cameraman is mispelled. Whether or not that's why it cannot run is unknown.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 3 Apr 2019
Your code is assuming that camerman.tif is RGB without testing to see if that is true.
You can test it by looking at size() and ndims(), or by looking at the output of imfinfo()

More Answers (1)

KALYAN ACHARJYA
KALYAN ACHARJYA on 2 Apr 2019
Edited: KALYAN ACHARJYA on 2 Apr 2019
img = imread('cameraman.tiff'); % Read the image
[rows, colm, dim]=size(img);
Here rows and clom gives the number of rows and column in the image
Whereas dim give the dimention of the image. In adition, if you wish to extract the color plane- here it is
red_plane=img(:,:,1); % Red Channel
green_plane=img(:,:,2); % Green Channel
blue_plane=img(:,:,3); % Blue Channel
Hope it Helps!

Products

Community Treasure Hunt

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

Start Hunting!