Feature AND | Steve on Image Processing

一月 7, 2011 留下评论

Feature AND | Steve on Image Processing


I’m going to take a break from looking at M&Ms this week and instead consider a question that Richard asked yesterday:

"I have two binary images of the same size. I want to select regions from image one, where that region has to partially overlap with a region from image two."

I’ve seen this called the "Feature-AND" operation, and you can use the Image Processing Toolbox functionimreconstruct to do it. I’ll use one of the toolbox sample images to show you how.

bw = imread('text.png');

Suppose I’ve got a "marker" image that has a thick line running down the diagonal, like this:

stripe = logical(eye(256));
stripe = imdilate(stripe, ones(3,3));

Now ask the question, "Which objects in the original image touch the line?" It’s easy to use a simple elementwise AND to see which pixels in the original image touch the line:

touching_pixels = bw & stripe;

Now to get the entire objects that are touching the line, apply an operation called morphological reconstruction, which is what imreconstruct does. This function takes two inputs, a marker image and a mask image. Use the touching pixels as the marker image, and use the original image as the mask image.

marker = touching_pixels;
mask = bw;
out = imreconstruct(marker, mask);


Here’s another variation: "Which objects in the original image contain a vertical stroke that’s at least 11 pixels tall?"

Start by eroding the original image by a vertical line structuring element.

se = strel(ones(11,1));
bw_eroded = imerode(bw, se);

You can see that many characters are gone completely. If we define the pixels that are left as the marker image, then reconstruction gives us back the complete objects:

marker = bw_eroded;
out = imreconstruct(marker, mask);

This is a very useful operation, and I recommend that you add it to your bag of image processing tricks.



十一月 8, 2010 留下评论

60 Ways To Make Life Simple Again



When we were young life was easier, right? I know sometimes it seems that way. But the truth is life still is easy. It always will be. The only difference is we’re older, and the older we get, the more we complicate things for ourselves.


You see, when we were young we saw the world through simple, hopeful eyes. We knew what we wanted and we had no biases or concealed agendas. We liked people who smiled. We avoided people who frowned. We ate when we were hungry, drank when we were thirsty, and slept when we were tired.


As we grew older our minds became gradually disillusioned by negative external influences. At some point we began to hesitate and question our instincts. When a new obstacle or growing pain arose, we stumbled and a fell down. This happened several times. Eventually we decided we didn’t want to fall again, but rather than solving the problem that caused us to fall, we avoided it all together.


As a result, we ate comfort food and drank alcohol to numb our wounds and fill our voids. We worked late nights on purpose to avoid unresolved conflicts at home. We started holding grudges, playing mind games, and subtly deceiving others and ourselves to get ahead. And when it didn’t work out, we lived above our means, bought things we didn’t need, and ate and drank some more just to make ourselves feel better again.

因此,我们吃着安慰食品,喝着酒来麻木自己填补空虚。我们工作到很晚,就是为了避免家里永无休止的冲突。我们开始抱怨,打心理战,巧妙地欺骗别人从而使自己获得成功。当那些都不起作用的时候, 我们透支消费, 买一些我们并不需要的东西,吃很多,喝很多,一切只不过是为了让自己感觉好一点而已。

Over the course of time, we made our lives more and more difficult, and we started losing touch with who we really are and what we really need.


So let’s get back to the basics, shall we? Let’s make things simple again. It’s easy. Here are 60 ways to do just that:



Life is not complex. We are complex.


Life is simple, and the simple thing is the right thing.


— Oscar Wilde 奥斯卡 沃尔德


Don’t try to read other people’s minds. Don’t make other people try to read yours. Communicate.

1. 不要去尝试解读别人的心理。也不要尝试让别人来了解你的。 只要交流,沟通就行了。

Be polite, but don’t try to be friends with everyone around you. Instead, spend time nurturing your relationships with the people who matter most to you.

2. 要有礼貌,但不要让周围的每个人都成为你的朋友。相反,要花时间那些对你有重要影响的人身上。

Your health is your life, keep up with it. Get an annual physical check-up.

3. 身体是革命的本钱,要关心自己的身体,每年定期做一次身体检查。

Live below your means. Don’t buy stuff you don’t need. Always sleep on big purchases. Create a budget and savings plan and stick to both of them.

4. 量入为出。不要去买那些不需要的东西。将大宗采购活动适当推迟。建立一个预算和储蓄计划,并且长期坚持下去。

Get enough sleep every night. An exhausted mind is rarely productive.

5. 每天晚上要有充足的睡眠。疲惫状态下工作是没有效率的。

Get up 30 minutes earlier so you don’t have to rush around like a mad man. That 30 minutes will help you avoid speeding tickets, tardiness, and other unnecessary headaches.

6. 提前30分钟起床,这样就不会像个疯子一样忙的团团转。这30分钟会帮助你避免超速罚单、迟到以及其他不必要的麻烦。

Get off your high horse, talk it out, shake hands or hug, and move on.

7. 不要自以为是,放下架子。有事大声说出来,跟人握一握手或者拥抱,然后继续前进。

Don’t waste your time on jealously. The only person you’re competing against is yourself.

8. 不要在嫉妒中浪费了时间。你唯一的对手就是你自己。

Surround yourself with people who fill your gaps. Let them do the stuff they’re better at so you can do the stuff you’re better at.

9. 要学着用别人的长处来弥补自己的短处。让别人做他们擅长的事情,这样你就能做你自己擅长的事情。

Organize your living space and working space.

10. 安排好你的生活空间和工作空间。

Get rid of stuff you don’t use.

11. 扔掉那些你不用的东西。

Ask someone if you aren’t sure.

12. 如果有你不确定的时候,要去问。

Spend a little time now learning a time-saving trick or shortcut that you can use over and over again in the future.

13. 多花一点时间学习一个可以节约时间的诀窍,这样能在以后反复使用。

Don’t try to please everyone. Just do what you know is right.

14. 不要去取悦所有人。只去做你认为对的事情。

Don’t drink alcohol or consume recreational drugs when you’re mad or sad. Take a jog instead.

15. 当你生气或沮丧时,不要饮酒或服用娱乐性药物,尝试用慢跑来代替。

Be sure to pay your bills on time.

16. 一定要按时支付账单。

Fill up your gas tank on the way home, not in the morning when you’re in a hurry.

17. 在回家的路上记得要加满油,而不是选择在慌慌张张的早上。

Use technology to automate tasks.

18. 使用技术来自动执行一些任务。

Handle important two-minute tasks immediately.

19. 迅速处理那些重要的但又可以很快完成的事情。

Relocate closer to your place of employment.

20. 搬到离工作单位更近的地方生活。

Don’t steal.

21. 不要偷窃。

Always be honest with yourself and others.

22. 始终诚实地对待自己还有他人。

Say “I love you” to your loved ones as often as possible.

23. 尽可能多的对你爱的人说“我爱你”。

Single-task. Do one thing at a time and give it all you got.

24. 单项任务。一次只做一件事情,并且要全力以赴。

Finish one project before you start another.

25. 完成一件工作以后再去开始另一个工作。

Be yourself.

26. 做你自己。

When traveling, pack light. Don’t bring it unless you absolutely must.

27. 旅行时要轻装上阵。除非有些东西是必需品。

Clean up after yourself. Don’t put it off until later.

28. 不要忘记把自己收拾干净。不要拖延。

Learn to cook, and cook.

29. 学习做饭,并经常自己做饭。

Make a weekly (healthy) menu, and shop for only the items you need.

30. 每周制作健康合理的菜单,购物时只买你所需要的东西。

Consider buying and cooking food in bulk. If you make a large portion of something on Sunday, you can eat leftovers several times during the week without spending more time cooking.

31. 要考虑批量购买和烹饪食物。如果你在星期天做了一大堆食物,你在以后的几天里不需要花很多时间做饭,就有的吃。

Stay out of other people’s drama. And don’t needlessly create your own.

32. 远离他人的生活闹剧。更不要无谓地将你自己的生活变成闹剧。

Buy things with cash.

33. 用现金买东西。

Maintain your car, home, and other personal belongings you rely on.

34. 保护好你的车、房子和其他属于你私人的财物。

Smile often, even to complete strangers.

35. 要经常微笑,即使是面对陌生人的时候。

If you hate doing it, stop it.

36. 如果不喜欢做某事,那就停下。

Treat everyone with the same level of respect you would give to your grandfather and the same level of patience you would have with your baby brother.

37. 对待每一个人,要像对待你的爷爷一样尊重,要像对你的弟弟一样有耐心。

Apologize when you should.

38. 应该道歉的时候就道歉。

Write things down.

39. 把要做的事情写下来。

Be curious. Don’t be scared to learn something new.

40. 保持好奇心,不要害怕去学习新东西。

Explore new ideas and opportunities often.

41. 要经常探索发现新的思路和机会。

Don’t be shy. Network with people. Meet new people.

42. 不要害羞。多与人交流,建立人际关系,认识新的朋友。

Don’t worry too much about what other people think about you.

43. 不要去担心别人对你的看法。

Spend time with nice people who are smart, driven, and likeminded.

44. 与那些聪明的、上进的、志同道合的朋友们在一起。

Don’t text and drive. Don’t drink and drive.

45. 不要边发短信边驾车,不要喝酒驾车。

Drink water when you’re thirsty.

46. 口渴的时候要记得喝水。

Don’t eat when you’re bored. Eat when you’re hungry.

47. 无聊时不要吃东西,感觉饿了才吃。

Exercise every day. Simply take a long, relaxing walk.

48. 坚持每天锻炼身体。经常散步。

Let go of things you can’t change. Concentrate on things you can.

49. 放手那些你不能改变的事情。把精力放在你能做的事情上。

Find hard work you actually enjoy doing.

50. 努力寻找真正喜欢的事情。

Realize that the harder you work, the luckier you will become.

51. 要认识到越努力工作,你就会变得越来越幸运。

Follow your heart. Don’t waste your life fulfilling someone else’s dreams and desires.

52. 跟随着你的本心。不要浪费你的生命去实现别人的梦想和愿望。

Set priorities for yourself and act accordingly.

53. 分清轻重缓急,相应地采取行动。

Take it slow and add up all your small victories.

54. 慢慢来,不断积累你的每一点小成果。

However good or bad a situation is now, it will change. Accept this simple fact.

55. 目前的形势无论好坏,都会变化的。接受这个简单的现实。

Excel at what you do. Otherwise you’ll just frustrate yourself.

56. 擅长自己在做的事情,否则只会让自己很沮丧。

Mature, but don’t grow up too fast.

57. 要变得成熟,但是不要成熟地太快。

Realize that you’re never quite as right as you think you are.

58. 要知道,你永远也不会像你自己想的那样完全正确。

Build something or do something that makes you proud.

59. 做一些能够让你感到骄傲的事情。

Make mistakes, learn from them, laugh about them, and move along.

60. 不怕犯错误,从错误中学习,然后一笑了之,继续前行。

Oh, and enjoy life’s simple pleasures. They’re free and better than anything money can buy.



关于Latent Dirichlet Allocation及Hierarchical LDA模型的必读文章和相关代码

十月 28, 2010 留下评论


(1)D. M. Blei, et al., “Latent Dirichlet allocation,” Journal of Machine Learning Research, vol. 3, pp. 993-1022, 2003.

(2)T. L. Griffiths and M. Steyvers, “Finding scientific topics,” Proceedings of the National Academy of Sciences, vol. 101, pp. 5228-5235, 2004.

(3)D. M. Blei, et al., “Hierarchical Topic Models and the Nested Chinese Restaurant Process,” NIPS, 2003.


(5)Teh的关于Dirichlet Processes的视频教程:http://videolectures.net/mlss07_teh_dp/



(8)G. Heinrich, “Parameter Estimation for Text Analysis,” http://www.arbylon.net/publications/text-est.pdf


(1)P. Johnson and M. Beverlin, “Beta Distribution,” http://pj.freefaculty.org/ps707/Distributions/Beta.pdf

(2)M. Beverlin and P. Johnson, “The Dirichlet Family,” http://pj.freefaculty.org/stat/Distributions/Dirichlet.pdf

(3)P. Johnson, “Conjugate Prior and Mixture Distributions”, http://pj.freefaculty.org/stat/TimeSeries/ConjugateDistributions.pdf

(4)P.J. Green, “Colouring and Breaking Sticks:Random Distributions and Heterogeneous Clustering”, http://www.maths.bris.ac.uk/~mapjg/papers/GreenCDP.pdf

(5)Y. W. Teh, “Dirichlet Process”, http://www.gatsby.ucl.ac.uk/~ywteh/research/npbayes/dp.pdf

(6)Y. W. Teh and M. I. Jordan, “Hierarchical Bayesian Nonparametric Models with Applications,”


(7)T. P. Minka, “Estimating a Dirichlet Distribution”, http://research.microsoft.com/en-us/um/people/minka/papers/dirichlet/minka-dirichlet.pdf

(8)北邮论坛的LDA导读:[导读]文本处理、图像标注中的一篇重要论文Latent Dirichlet Allocation,http://bbs.byr.edu.cn/article/PR_AI/2530?p=1

(9)Zhou Li的LDA Note:http://lsa-lda.googlecode.com/files/Latent%20Dirichlet%20Allocation%20note.pdf

(10)C. M. Bishop, “Pattern Recognition And Machine Learning,” Springer, 2006.




(3)Gibbs LDA(C++):http://gibbslda.sourceforge.net/

(4)Delta LDA(Python):http://pages.cs.wisc.edu/~andrzeje/research/deltaLDA.tgz

(5)Griffiths和Steyvers的Topic Modeling工具箱:http://psiexp.ss.uci.edu/research/programs_data/toolbox.htm






(1)S. Geman and D. Geman, “Stochastic Relaxation, Gibbs Distributions, and the Bayesian Restoration of Images,” Pattern Analysis and Machine Intelligence, IEEE Transactions on, vol. PAMI-6, pp. 721-741, 1984.

(2)B. C. Russell, et al., “Using Multiple Segmentations to Discover Objects and their Extent in Image Collections,” in Computer Vision and Pattern Recognition, 2006 IEEE Computer Society Conference on, 2006, pp. 1605-1614.

(3)J. Sivic, et al., “Discovering objects and their location in images,” in Computer Vision, 2005. ICCV 2005. Tenth IEEE International Conference on, 2005, pp. 370-377 Vol. 1.

(4)F. C. T. Chua, “Summarizing Amazon Reviews using Hierarchical Clustering,” http://www.mysmu.edu/phdis2009/freddy.chua.2009/papers/amazon.pdf

(5)F. C. T. Chua, “Dimensionality Reduction and Clustering of Text Documents,” http://www.mysmu.edu/phdis2009/freddy.chua.2009/papers/probabilisticIR.pdf

(6)D Bacciu, “Probabilistic Generative Models for Machine Vision,” http://www.math.unipd.it/~sperduti/AI09/bacciu_unipd_handouts.pdf


十月 23, 2010 1条评论




九月 5, 2007 2 条评论












[2006年5月24日 22时38分39秒首先发布于qq空间]


重回MSN,重整MSN Space

十二月 19, 2006 6 条评论
    自从那次出院以后,暑假在家里养病,躺了2个月,几乎什么事也不能做,连NBA 06都没打~`9月份,回到学校以后,苦于上网条件实在不足,以及其他的许多烦人的事,所以也没怎么上MSN的!现在,情况终于有所好转,宿舍已经宽带了,而且自己也不像以前几个月,把导师和师姐的任务看的很重,觉得现在轻松了很多,也学会了糊任务交差和睡懒觉,所以闲了很多,有时间做自己的事情,比如早上起来看NBA比赛,几乎每天都看的,Houston的比赛更是不缺,宁愿缺课,也不缺比赛的,哈哈。下午就上上课或者上网看看新闻,陪宿舍人玩玩游戏的。整一感觉,自己变了很多~

出院 了

六月 29, 2006 2 条评论