how to calculate mean and variance of the image using W*W sliding window
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
contrast enhancement is to improve the contrast of lesions for detection using a w*w sliding window with assumption that w is large enough to contain a statistically representative distribution of the local variation of lesions. where the sigmoid function used with the maximum and minimum intensity values of smooth green channel image,respectively. mean and variance of intensity values with in the window.
CAN U HELP ME WITH CODING
Accepted Answer
Image Analyst
on 21 Aug 2013
Try this:
meanImage = conv2(grayImage, ones(w)/w^2);
stdDevImage = stdfilt(grayImage, ones(w)/w^2);
varianceIMage = stdDevImage .^2;
10 Comments
kalaivaani
on 22 Aug 2013
Edited: kalaivaani
on 22 Aug 2013
dear image analyst, I need the output mean and variance of the sliding window in the matrix form(may be image for my work) so that i need to subtract from the image matrix and divide it by the variance (ie, to substitute in the formula sigmoid function) to perform local contrast enhancement
Image Analyst
on 22 Aug 2013
Sounds like a Wallis filter ( http://www.dtic.mil/dtic/tr/fulltext/u2/a248301.pdf). Okay, just remember to cast your images to double before subtracting and dividing or your results will be rounded to integers and clipped to the range 0-255.
kalaivaani
on 23 Aug 2013
Edited: kalaivaani
on 23 Aug 2013
given that the sigmoid function formula is 1 / {[1+exp((M-I)/V)]} were M is the mean of the intensity values in the w*w sliding window(subimage), V is the variance of the intensity values in the w*w sliding window(subimage) *I is the *colored image *
Image Analyst
on 23 Aug 2013
OK.
kalaivaani
on 24 Aug 2013
I got the standard deviation of the image as output, but while converting it to variance of the image it shows the error that matrix should be square, how can i convert the image matrix to square with out the loss of information
Image Analyst
on 24 Aug 2013
It doesn't need to be square. Did you use the dot in .^2? Or did you just do ^2?
kalaivaani
on 24 Aug 2013
Edited: kalaivaani
on 24 Aug 2013
just ^2 ,is it wrong
Image Analyst
on 24 Aug 2013
Yes. That's wrong. That's a matrix multiply, not an element-by-element multiply. So it's like A*B, except it's A*A, and as you know the number of columns of A must match the number of rows in B, but since A is B, the number of columns of A must match the number of rows of A so it must be square. But you don't want that. You want an element by element multiple. I didn't add the dot in there just for the fun of it - you need it.
kalaivaani
on 26 Aug 2013
the error showing is * ??? Error using ==> mldivide * Matrix dimensions must agree. * what should i do how can i code the formula sigmoid function formula is 1 / {[1+exp((M-I)/V)]} were M is the meanimage, V is the varianceimage , I is the color image * and my code is sigmoid = 1/(1+exp((double(meanImage)-double(green))./double(sdImage))); * is it correct?
Image Analyst
on 27 Aug 2013
Use the 'same' option in conv2 to get the same size image.
meanImage = conv2(grayImage, ones(w)/w^2, 'same');
More Answers (0)
Categories
Find more on Image Filtering and Enhancement in Help Center and File Exchange
Products
See Also
on 21 Aug 2013
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)