How do u change the intensity ratio of the object in the gray scale image?

2 次查看(过去 30 天)
Hi, there this is my first post in the communities, if I am not clear in the question description, please let me know. I am doing my best to give a precise description.
First of all, here is a dozen of gray-scale images. And one of them look like this
It has only one object in the image, and it might have different shapes and sizes. Assume it's total intensity I calculated is sum(sum(I)) = 25,000. I want to set a standard total intensity as 50,000. Thus I need to upscale the object and resize the image so it should look like the following image.
Please noted that the dimension/size of the image should stay the same, but the ratio the object takes in the image changes.
Any suggestion and hints would be greatly appreciated. Thank you all for your time and help!

回答(2 个)

Nut
Nut 2016-5-24
编辑:Nut 2016-5-24
Hi,
if all pixels outside the central region are zeros, I think you can solve this issue enlarging the entire image using the "imresize" functions: it should be possible to set the new dimensions starting from the total intensity you need. Then, you could use the "imcrop" function to cut the image and get back it with the same dimensions of the input image. Both functions are included in the Image Processing Toolbox.
If NOT all pixels outside the central region are zeros, you may need before to set a threshold intensity, to assign the value zero to all pixels with a value lower than the threshold.
I hope it is clear and helpful.
  1 个评论
Donny Liu
Donny Liu 2016-5-30
RoBo, thank you for taking time answering my question. it's right that all pixels outside the central region are zeros. I will try it out and let you know how it works.

请先登录,再进行评论。


Image Analyst
Image Analyst 2016-5-30
It's a little tricky and you won't get it right on the first try if you scale up by interpolating - you'll have to iterate if you need it exact. Here are the steps
  1. Get the intensity sum of the blob: initialSum = sum(grayImage(mask))
  2. Compute the scaling factor (desiredIntensitySum)/(initialSum)
  3. Put the image and that scaling factor into imresize().
  4. Find the centroid of the enlarged/shrunk blob and crop to desired size around it. Note that you may clip off edges of the blob if you had to enlarge it too much to get your desired intensity. It's not possible in all cases to both get the sum of the intensities to some desired value and be able to fit the whole blob in some specified rectangle. Like, what if the desired sum was 42 quadrillion? You'd have to enlarge that image so much that there is no way it would fit into, say, a 1k-by-1k image. And if you crop at 1k-by-1k then you won't have a sum of 42 quadrillion anymore.

类别

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