이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
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!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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 (한국어)