How to create a Gaussian Curve over a Bar Plot created by Histogram?
4 ビュー (過去 30 日間)
古いコメントを表示
Tawsif Mostafiz
2021 年 5 月 22 日
回答済み: Sulaymon Eshkabilov
2021 年 5 月 22 日
Hi, I am trying to fit a Gausian Curve over a histogram plot derived from an image. The code for it is as follows:
subplot(2,2,3)
imhist(maskedRgbImage), title('Histogram of Tumor');
xlim([-10 200])
ylim([0 100])
And the output looks like this:
I want to fit a gaussian curve over it,. Something like this:
I found some code related to this. But the problem of implementing them is that these code work with random values like:
data=randn(1,10000)*5;
But I cannot be able to input the histogram data inside the code. How can I do it? My ultimate objective is to find Mean, Standard Deviation and Variance.
0 件のコメント
採用された回答
Sulaymon Eshkabilov
2021 年 5 月 22 日
Hi,
(1) You need to read the data of your image being processed, imread()
(2) Convert data into single or double precision format if necessary. The Variance calculation requires it
(3) Data Processing: imhist, histfit, svd, etc.
See this code of mine for your exercise:
DATA = imread('IMAGE.jpeg');
imhist(DATA(:,:,1))
RED = DATA(:,:,1);
GREEN = DATA(:,:,2);
BLUE = DATA(:,:,3);
% Image histogram and distribution fit
subplot(311)
RD=imhist(RED, 100);
histfit(RD, 100, 'kernel'); title('Red color distribution & its fit')
subplot(312)
GD=imhist(GREEN, 100);
histfit(RD, 100, 'kernel'); title('Green color distribution & its fit')
subplot(313)
BD=imhist(BLUE, 100);
histfit(RD, 100, 'kernel'); title('Blue color distribution & its fit')
% STD calcs: std2()
STD_R=std2(RED);
STD_G=std2(GREEN);
STD_B=std2(BLUE);
% MEAN calcs: mean2()
MEAN_R = mean2(RED);
MEAN_G = mean2(GREEN);
MEAN_B = mean2(BLUE);
% VARIANCE calcs: var(var(double(RED)))
...
Good luck
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Scatter Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!