intensity value of the pixel located

18 ビュー (過去 30 日間)
Nour George
Nour George 2020 年 6 月 26 日
コメント済み: Nour George 2020 年 6 月 29 日
I have this question :
1-Read an image.
2-Show that image.
3-Write the image to the disk by new name.
4-Show additional info about image.
5-How to get the size of that image.
6-What is the intensity value of the pixel located at position(4,7)?
*I solved the previous five questions, but how can I solve the sixth question
figure
image=imread('Picture2.jpg')
imshow(image)
gray = rgb2gray(image)
imwrite(image,'House.jpg');
information = imfinfo('House.jpg')
information = information.FileSize

採用された回答

Aditya Verma
Aditya Verma 2020 年 6 月 27 日
編集済み: Aditya Verma 2020 年 6 月 27 日
Your image is stored as a matrix in MATLAB. So, for getting the pixel intensity value you need to read the image:
image_mat = rgb2gray(imread('image.jpg')); % image_mat is simply a matrix
disp(image_mat(4, 7)); % Intensity at (4,7)
  4 件のコメント
Aditya Verma
Aditya Verma 2020 年 6 月 27 日
By the way, if you're new to MATLAB or programming I would recommend you to take the free MATLAB Onramp course.
Nour George
Nour George 2020 年 6 月 29 日
The picture is colored, should I use rgb2gray()?

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2020 年 6 月 27 日
Do not use image as the name of your variable. It is the name of a built-in function that you will destroy (temporarily).
The assignment did not say anything about converting to gray scale so why did you use rgb2gray()?
To get the value of a pixel, you can use impixel() or simply index it. A color image will have 3 intensities, one for each color channel.
  1 件のコメント
Image Analyst
Image Analyst 2020 年 6 月 27 日
Well I'm sure you saw the code in the help for impixel:
RGB = imread('peppers.png');
% Determine the column c and row r indices of the pixels to extract.
c = [1 12 146 410];
r = [1 104 156 129];
% Return the data at the selected pixel locations.
pixels = impixel(RGB,c,r)
So I'm not sure what you're asking. Do need help in modifying that code like this?
theColor = impixel(image_mat, 7, 4);
Remember it's columns that come first, not rows. But that was so easy that I'm certain you would have been able to do that simple change of putting in 7 and 4 for the column and row and changing the name of the image variable, so I'm not really sure what you're asking.

サインインしてコメントする。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by