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

2 ビュー (過去 30 日間)
Donny Liu
Donny Liu 2016 年 4 月 26 日
回答済み: Image Analyst 2016 年 5 月 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.

Community Treasure Hunt

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

Start Hunting!

Translated by