3D Histogram of a true color (RGB) image

4 ビュー (過去 30 日間)
Abdul Gaffar
Abdul Gaffar 2021 年 1 月 25 日
コメント済み: DGM 2025 年 4 月 9 日
I have to plot 3D histogram of a true color image, as shown in the attached screenshot.

回答 (1 件)

Vedant Shah
Vedant Shah 2025 年 3 月 12 日
To plot a 3D histogram of a true colour image, try the following steps:
1. Convert it to a grayscale image, focusing on intensity values.
2. Then proceed by using the "meshgrid" function to determine the X and Y coordinates.
3. Finally, plot the 3D surface using the "surf" function.
For more information about the meshgrid and surf functions, you can refer to their official MATLAB documentation using the following commands:
web(fullfile(docroot, "/matlab/ref/meshgrid.html"))
web(fullfile(docroot, "/matlab/ref/surf.html"))
Below is a reference MATLAB code snippet:
img = imread('image.jpg');
grayImg = rgb2gray(img);
grayImg = double(grayImg);
[X, Y] = meshgrid(1:size(grayImg, 2), 1:size(grayImg, 1));
figure;
surf(X, Y, grayImg, 'EdgeColor', 'none');
colormap jet;
colorbar;
This script generates a 3D surface plot where the height represents pixel intensity. Darker regions correspond to low intensity, while brighter regions indicate higher intensity values.
  1 件のコメント
DGM
DGM 2025 年 4 月 9 日
That's not a histogram. That's just an intensity map.

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

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by