How to average every single pixel with its surroundings points so each pixel got the same value.

조회 수: 4 (최근 30일)
Hello everyone,
I got a grid that contain two numbers of information for every pixel.
But, what I need to do is to average every pixel in grid number one, so they equal the number 10 or almost 10 if not possible. When the pixel reach the number by combining the pixel values from it's surroundings, the pixel also include information from grid number two, which is the number I seek for.
Shortly again:
I want to find the value in grid number 2 for every time grid number 1 reach a value around 10. What is troublesome is that the size of the combining grid vary from pixel to pixel.
Does anyone have a clue to handle this problem? Do I need to use a filter that runs though every pixel or some kind of integration over an area of 10?? The original data is in 3D and I don’t know if it best do this averaging over a volume (like a cubic) or like a square in 2D slice or something third....
Thank you for your time! :)

채택된 답변

Image Analyst
Image Analyst 2016년 8월 13일
OK, I did it for you. See attached m-file. For a full size image, it would take a huge amount of time to check every possible permutation for the one for the sum that is closest to 10. Why do you think you need to do this? What is the use case? Also note that there will be edge effects because the corners have only 4 elements and the edges have only 6 elements so their sums will tend to be lower.
  댓글 수: 5
Image Analyst
Image Analyst 2016년 8월 14일
The rate is the rate. It doesn't matter if it's 1 milligram or 10 grams or a kilogram.
If you have the rate (Watts per kg) and you have the mass (in kg), then you can find the power (Watts) in that voxel by multiplying the rate in W/kg by the actual mass in kg of that voxel. Just look at the units: (W/kg)*kg -- the kg cancel out and you get Watts.
Nick Yin Larsen
Nick Yin Larsen 2016년 8월 15일
편집: Nick Yin Larsen 2016년 8월 15일
Maybe it is because I am not at explaining stuff that I am not that clear in my language, sorry... Well I am not suppose to cancel the kg out from the W/kg, since my result should be like does an average area of 10 gram of tissue exceed 3.2W/kg as the law requires.
That is why in the mass map, every pixel need to combine the weight until it each the value of 10, which your example shows very clearly. Beside that, the W/kg map have to average over the same pixels as the 10 gram map did.
I have not done anything alike this before and I am very grateful for your time and guidance! :)
Does it help if I also got the information of the grid size like x, y and z and each voxel is 1mm^3?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2016년 8월 13일
You'll probably have to use nlfilter() because you'll need to apply some special filter that applies special algorithm to each window location. The brute force way (which may be the only way) is to use perms() to check every possible combination of elements in the window. Then check all the sums against 10 to see which cam closest. It's really not that hard so give it a try.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by