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

2 views (last 30 days)
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!

Answers (2)

Nut
Nut on 24 May 2016
Edited: Nut on 24 May 2016
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 Comment
Donny Liu
Donny Liu on 30 May 2016
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.

Sign in to comment.


Image Analyst
Image Analyst on 30 May 2016
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.

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!