現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
Problem understanding image processing tool
2 ビュー (過去 30 日間)
古いコメントを表示
Saqib
2014 年 4 月 18 日
Hi, i am new to MATLAB image processing.
I want to carry out my B.Tech project with regard to the determination of "Moisture Content" using image processing & in this regard i downloaded a research paper
An approach to estimate moisture content of apple with image processing method by Farshad Vesali, Masoud Gharibkhani and Mohmmad Hasan Komarizadeh
I was successfully able to generate the BW image as given below by using the help of the video "image processing made easy" video on the MATLAB site but i am unable to understand how to get the values of zi for using in equations 1 through 7 as shown in the images below and am not able to understand the paragraph just after the equations.
So, if anyone of you may be interested in helping me out i understanding these equations and helping me in using MATLAB Image Processing toolbox please post a REPLY as soon as possible as i have to report the project on Monday.
Thanks
If you can help me on Facebook or SKYPE also through video chat also.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/161224/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/161225/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/161228/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/161232/image.png)
採用された回答
Image Analyst
2014 年 4 月 19 日
編集済み: Image Analyst
2014 年 4 月 21 日
Well I did the masking part of your B.Tech project for you in http://www.mathworks.com/matlabcentral/answers/126363#answer_133893. I imagine you'll need to do some of the project yourself, so programming in those 5 equations seems simple enough. I'll give you the first two as a freebie:
I = mean2(grayImage);
v = var(grayImage);
S = 1 - (1 / (1+v));
pz is the pdf, which is the normalized histogram so
[pz, z] = imhist(grayImage) / numel(grayImage);
I trust that, knowing that, you can do equations 5, 6, and 7 yourself, right?
38 件のコメント
Image Analyst
2014 年 4 月 19 日
Please format your code. This will show you how: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
What is untitled.png? Can you attach that. And what are the two images you are having to decide between, and how will I know if I've chosen the correct one? What is the criteria for success?
Saqib
2014 年 4 月 20 日
編集済み: Saqib
2014 年 4 月 20 日
Above i have pasted the fully formatted code that i have been able to generate till now assuming MSE1 is the zi taken in the equation & PSNR is p(zi) as taken in the above equations. Now i just wanted to know whether i am doing the right thing or the wrong. Basically i want to estimate moisture content using the above equations and use the same in ANN but i don't actually know how to correlate the two and how to obtain the zi & p(zi) from the images And also i was asking whether the author of the paper has derived zi & p(zi) from Fig1 (A&B) or Fig 3 (A&B)
Image Analyst
2014 年 4 月 20 日
編集済み: Image Analyst
2014 年 4 月 20 日
They got them from the M image, which is shown in figure 1, though that's zoomed in on a small area and not showing the entire M image.
z is the histogram like I said. You can tell by looking at the equations. z(i) is the counts at gray level (i-1). It is not the MSE. Not sure why you'd think that - just look at the equations for mean gray level and entropy and you can tell that z is the histogram counts.
Image Analyst
2014 年 4 月 20 日
I don't know what line 59 is. Please give the full error message - all of it, ALL the red text. Don't snip out a small chunk of it. I need traceback lines of code and everything. Unfortunately, now you'll have to wait until tomorrow because I'm headed to bed.
Saqib
2014 年 4 月 20 日
Meanwhile can we start from the beginning so i understand he whole process easily by getting M images from the main image & processing it to use it i the equations above so its easy & fast & no time is wasted on non-necessary stuff as i user a lot of time in finding MSR and finalyy laernt that it is of no use as it is not used in the equations above. Thanks
Image Analyst
2014 年 4 月 20 日
That line 59 is not what's causing the error. I don't know how many more times I'll be willing to ask "Please give the full error message - all of it, ALL the red text. " or how long I'll be willing to wait if you don't help me to help you. You have NOT yet posted the full error message, though you think you did. There is still some red text with the traceback that you did not copy here.
Image Analyst
2014 年 4 月 20 日
I thought you had a script. I didn't know you were doing it the hard way by typing everything into the command line. It says that the input argument to var() must be double, so make it double:
v = var(double(grayImage));
Image Analyst
2014 年 4 月 20 日
v is a vector. If you want the variance of the whole image instead of column-by-column, use (:)
v = var(double(grayImage(:)));
Saqib
2014 年 4 月 20 日
編集済み: Saqib
2014 年 4 月 20 日
thanks a lot.
which one is better to use? whole image or column by column... (please tell me from the equation)
this is about zi
Now can you help me with p(zi)
& how do i extract only the aple portion from the Untitled.png image so that i can exactly get it going.
Image Analyst
2014 年 4 月 20 日
They probably want the variance of just the masked apple area, so you'd do:
varianceOfAppleOnly = var(double(grayImage(appleMask)));
To get the histogram with the apple region only:
counts = hist(grayImage(appleMask), 256);
Image Analyst
2014 年 4 月 20 日
I don't know what you called it. What did you call the binary image that defines apple and not apple? Did you call it mask, foreground, binaryImage, or something else? Whatever you used, use that name.
Saqib
2014 年 4 月 20 日
Couldn't understand this line "What did you call the binary image that defines apple and not apple? "
Is it the "Mask Image" of this page
Thannks
Image Analyst
2014 年 4 月 20 日
It was called "mask" there, so use that.
varianceOfAppleOnly = var(double(grayImage(mask)));
counts = hist(grayImage(mask), 256);
I'm afraid you don't understand the concept of a mask or else you would have known this. Basically a mask is a logical array that says where to use elements from the array, and where to ignore elements. If the value is true or 1, it will use those elements, and if the value is false or 0, it won't use that. So when you say grayImage(mask) it only uses the pixels from grayImage that are white when you display the mask and it won't use any pixels from the parts of the mask that look black. Does that explain it enough? If you're still unsure, let me know and we can try to work up some simple examples with small arrays.
Saqib
2014 年 4 月 20 日
編集済み: Saqib
2014 年 4 月 20 日
i used the code
varianceOfAppleOnly = var(double(grayImage(mask)));
counts = hist(grayImage(mask), 256);
but it shows this error
??? Index exceeds matrix dimensions.
Ys i understood mask a lil bit.
N sir can you please answer a little bit faster please as its already 11pm here & i have to go to sleep ater half an hour and when i am back then u have to go to sleep
Image Analyst
2014 年 4 月 20 日
Do this
whos grayImage
whos mask
[rows, columns, numColors] = size(grayImage);
[rowsm, columnsm, numColorsm] = size(mask);
what do you see?
Saqib
2014 年 4 月 20 日
編集済み: Saqib
2014 年 4 月 20 日
Name Size Bytes Class Attributes
grayImage 369x304 112176 uint8
Name Size Bytes Class Attributes
mask 369x304 112176 logical
& now its showing this error
??? Error using ==> times
Integers can only be combined with integers of the same class, or scalar doubles.
Error in ==> hist at 78
xx = miny + binwidth*(0:x);
Saqib
2014 年 4 月 20 日
how?
also please can you help me with p(zi) now - waht it is & how to obtain it.
and what is the "L" used i the equations above.
Thanks.
I'll be back after nearly 10 hrs from now as i have t go to bed.
So please post the reply on all the three issues.
Thaks a lot.
Image Analyst
2014 年 4 月 20 日
編集済み: Image Analyst
2014 年 4 月 20 日
How? Just like with the others.
[z, grayLevels] = imhist(double(grayImage));
Sorry I can't do it all for you. First, I don't have time. Second, you didn't attach your code or images. And third, it's YOUR project and I'm pretty sure your professor is not saying "Please get someone on the web to code up this paper for you, so you can turn in their work as your own."
Saqib
2014 年 4 月 20 日
sorry but i m not asking you to do it all
i have to use all the corresponding values derived from here in neural networks and my professor gave me the chance of getting xternal help regarding imahe processing as i have never done it before. also i cant understand on how to get the values as i dont rven know what the values ate and its basically done on the images of the paper and i have to capture and generate the whole data myself. so i wanted help with this part ANN and rest i will do myself. so if yoiu wish' help me a bit more bdw thanks for all the help till now
Image Analyst
2014 年 4 月 20 日
I don't know neural networks so either Greg or your professor can help there. Hopefully you're getting the histogram now.
Saqib
2014 年 4 月 21 日
I tried his code
>> [z, grayLevels] = imhist(double(grayImage));
>> count= imhist(double(grayImage));
>> imshow(count))
but it shows the follwing
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/178492/image.png)
Image Analyst
2014 年 4 月 21 日
count is a histogram , not an image . You should display it with bar() not imshow().
And I wouldn't do both and I wouldn't use imhist on a double image unless you want to make sure it's in the range 0-1. It's easier to use hist() on a double image.
Image Analyst
2014 年 4 月 21 日
Just asking later doesn't mean I forgot what I said earlier: " I imagine you'll need to do some of the project yourself, so programming in those 5 equations seems simple enough. I'll give you the first two as a freebie". If I do all the equations for you, then you will not have done enough yourself for your project. Like I said they're simple. You almost type them out exactly as they appear. Please make an attempt. It's not that hard. There is a function called sum() you know.
Saqib
2014 年 4 月 21 日
I would have done it myself but i haven't read MATLAB.
So, i was able to understand a little bit about the program.
So, i was searching online help.
Also i have to do image capturing & Neural Network etc. myself plus the manual determination. So these 5 equations form a very small part o the entire project
Image Analyst
2014 年 4 月 21 日
I'll give you another two;
[pz, z] = imhist(grayImage) / numel(grayImage);
U = sum(pz.^2);
e = -sum(pz .* log(pz));
That leaves only one simple equation left for you to do . Tell me what you got for it.
Saqib
2014 年 4 月 22 日
thanks a lot for these 2 also i'll try them as soon as possi le and get back to you
Saqib
2014 年 4 月 22 日
the first lineof the code shows this error
>> [pz, z] = imhist(grayImage) / numel(grayImage);
??? Error using ==> mrdivide
Too many output arguments.
Image Analyst
2014 年 4 月 22 日
編集済み: Image Analyst
2014 年 4 月 22 日
Use ./ instead of /
And, no that's not the equation. You aren't even cubing it and don't have a multiplication sign.
Saqib
2014 年 4 月 22 日
still the same error
[pz, z] = imhist(grayImage)./numel(grayImage);
??? Error using ==> rdivide
Too many output arguments.
Image Analyst
2014 年 4 月 22 日
Sorry, shouldn't have tried it all in one step. Needed 2 lines of code to do it. Try this:
[pz, z] = imhist(grayImage); % pz is the counts.
% Normalize so that the area under the curve = 1.
pz = pz ./ numel(grayImage);
Image Analyst
2014 年 4 月 22 日
Looks like you need to use the log conversion functions to get log to the base 2, which is not in MATLAB. Also you need to make sure pz if not zero for any value because the log of that is -infinity.
Saqib
2014 年 4 月 22 日
I = 211.448117
v = 4864.005420
S = 1.000000
U = 0.508117
e = NaN
mew = -360081.533419>>
actually for pz its showing an array & not a single value
this might be causing he error i think
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)