how to make the ratio of white pixel and black pixel of two different pictures be same?
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
i have two different pictures including human silhouette. the ratio of black vs white pixel in first picture is: 0.2618 while its : 0.1085 on the second picture. now i want to have the ratio of the second picture be same (or nearly same) as the first picture without hampering the black pixels of either picture. how do i do it? btw, I am new in matlab and in this group. so please guide me. thanks in advance.
Accepted Answer
Image Analyst
on 30 Aug 2012
You can't do that. It doesn't even make sense. It's impossible. If the ratio of black to white pixels changes you have to change either the number of black or white pixels. So unless you scale the image (to make the white object bigger) and then crop off some of the black, you're out of luck.
12 Comments
Sayak
on 3 Sep 2012
thanks for the ans. What if I calculate the image size then no of black pixel then no of white pixel for both the pictures. now resizing(resize()) the image according to corresponding pixel ratio. Actually I have done that but the problem is either the picture is getting hazy or its being cropped in a wrong manner. Can you tell me how to get rid of it?
Image Analyst
on 3 Sep 2012
Like I said, you can't do that. What you're probably doing is to calculate the number of white pixels and shrinking the image by the right factor and padding with extra zeros so that all the white foreground silhouettes of the people are the same relative size in the image. For example
- calculate size of person's white silhouette
- determine factor = (desired # pixels) / (actual #pixels)
- newImage = imresize(originalImage, factor);
- [newRows newCols] = size(newImage);
- determine how many rows and columns to send into padarray()
If it's blurry, you're probably using gray level. Not sure why that's a problem - eventually you're probably going to binarize (threshold) anyway.
Sayak
on 3 Sep 2012
Yes that's the thing. Actually after counting and resizing the pixels I want to detect the edges(sobel) then count white pixels and then make a comparison with another variable. Now, whenever the pictures gets hazy the count of white pixels (after edge detection) gets changed heavily. I have tried imadjust() but still its not working good for me. Can you provide any help to make that blurry picture look good? Yes I have used rgb2gray(). Should I avoid it? And whats about binarize(threshold)?
Image Analyst
on 3 Sep 2012
Where did you upload your image to?
Actually I have done it, though in a different manner. My goal was to determine if two different images are of same kind or not (i.e. if they both are humans or other species). To do this, I started with human shade and then follow the following procedures.
1) read both the images and named them, global_img, sample_img
2) Convert them to rgb and detect edge (edge()) and save the non zero values in edge_white_global, edge_white_sample.
3) Measure both the images to check which is smaller and then re-size(imresize()) the smaller one to that of the greater one.
4)Then adjust the re-sized image (imadjust()) and calculate the edge again followed by measure the non zero value of that image.
5)At last checking if the non zero value of the re-sized image (edge) is equal or nearly equal to the global_img/sample_img.
6)If a match is found then both are of same species otherwise different species.
I have done it. But now the problem is whenever I'm resizing the smaller image then its getting blurred even after I have used (imfilter() and medfilt2()). How to avoid that problem? My pictures are: http://s8.postimage.org/ib1sruzol/global.jpg (global_img)
http://s12.postimage.org/kw8pdsbxp/global_boy.jpg (sample_img)
Again thanks for your valuable time.
Image Analyst
on 4 Sep 2012
I don't see the blurring. What is "edge gain" in step 4. And I don't understand step 5. All you're doing is comparing area fraction of the foreground of the two images - doesn't seem like a very robust method for checking species to me. What if a deer entered the frame? It's about the size of a human so it would be detected as human.
step 4: Its actually calculating the edge another time (again). And step 5 is matching the non zero values of the edge of the image that has been re-sized to the original global image.
You are right, I have also thought about it. What if more than one humans are present . But can't find a good way to handle this situation. Now against to your point the size of the human may also vary depending upon the picture itself. Lets consider two approaches,
1) Picture has been taken very close to the object(human).
2) Picture has been taken from very far range with a greater background.
The size of the first picture (human) will be greater than that of the second one.
There lie the problem so any suggestions?
Sayak
on 6 Sep 2012
Anyone? :(
16.7.4 Human Motion Understanding and Analysis
16.7.4.1 Human Motion Understanding and Analysis, Surveys, Reviews, Evaulations
16.7.4.2 Human Detection, People Detection, Pedestrians, Locating
16.7.4.2.1 Human Detection, People Detection, Pedestrians, Using Depth, Stereo
16.7.4.2.2 Human Detection, People Detection, Pedestrians, Using Body Parts, Body Shape
16.7.4.2.3 Evaluation, Human Detection, People Detection, Pedestrians
16.7.4.2.4 Counting People, Transportation System Monitoring, Queues, Crosswalks
16.7.4.2.5 Human Detection, Tracking, Infrared, IR, Thermal Images
16.7.4.3 Human Motion, General Analysis
16.7.4.4 Tracking People, Human Tracking, Pedestrian Tracking
16.7.4.4.1 Crowds, Tracking Multiple People, Multiple Pedestrian Tracking
and so on.
Sayak
on 8 Sep 2012
Thanks a lot. But I guess one needs IEEE access to read those paper and journals which in turn I do not have.
Apart from these can you suggest me any opinion with which I can match two shapes? Which may help me in my project.
Image Analyst
on 8 Sep 2012
I usually check the authors, then try to find their web site - usually a university. See if they made the paper available there. Other than that, you can buy the paper even if you are not a member of the society. If you have absolutely no money that you can put towards your work, then just search the internet for pattern recognition tutorials or reviews and see what pops up. For example, Szeliski's book http://szeliski.org/Book/
Sayak
on 8 Sep 2012
Excellent, thanks a lot.
More Answers (0)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Products
See Also
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)