Feature AND | Steve on Image Processing

一月 7, 2011 留下评论

Feature AND | Steve on Image Processing

From:http://blogs.mathworks.com/steve/2011/01/07/feature-and/

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');
imshow(bw)

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));
imshow(stripe)

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;
imshow(touching_pixels)

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);
imshow(out)

Neat!

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);
imshow(bw_eroded)

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);
imshow(out)

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

Advertisements
分类:Life

让生活变得简单的60种方法

十一月 8, 2010 留下评论

60 Ways To Make Life Simple Again

[zz]来自:http://www.marcandangel.com/2010/11/01/60-ways-to-make-life-simple-again/

PS:Yeeyan上有翻译(here),但是翻译的不好,很多错漏,趁着跑matlab的空闲,自己翻译了一下

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:

因此,让我们回到最初,好吗?让我们把事情变回简单。这很容易。这里有60个方法可以做到:

 

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.

嗯,那就来享受简单生活的乐趣吧。他们是免费的,而且比金钱买到的任何东西都要好。

分类:Life

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

十月 28, 2010 留下评论

LDA和HLDA:

(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.

(4)Blei的LDA视频教程:http://videolectures.net/mlss09uk_blei_tm/

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

(6)Blei的毕业论文:http://www.cs.princeton.edu/~blei/papers/Blei2004.pdf

(7)Jordan的报告:http://www.icms.org.uk/downloads/mixtures/jordan_talk.pdf

(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,”

http://www.stat.berkeley.edu/tech-reports/770.pdf

(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.

代码:

(1)Blei的LDA代码(C):http://www.cs.princeton.edu/~blei/lda-c/index.html

(2)BLei的HLDA代码(C):http://www.cs.princeton.edu/~blei/downloads/hlda-c.tgz

(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

(6)LDA(Java):http://www.arbylon.net/projects/

(7)Mochihashi的LDA(C,Matlab):http://chasen.org/~daiti-m/dist/lda/

(8)Chua的LDA(C#):http://www.mysmu.edu/phdis2009/freddy.chua.2009/programs/lda.zip

(9)Chua的HLDA(C#):http://www.mysmu.edu/phdis2009/freddy.chua.2009/programs/hlda.zip

其他:

(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条评论

  珍惜生活,珍惜时间,珍惜你自己,珍惜身边的每一个人!!
 
  小时候,看着满天的星斗,当流星飞过的时候,却总是来不及许愿,长大了,遇见了自己真正喜欢的人,却还是来不及。
 
  生命是最重要的,所以在我心里,没有事情是解决不了的。不是每一个人都可以幸运的过自己理想中的生活,有房有车当然好了,没有难道哭吗?所以呢,我们一定要享受我们所过的生活。
 
  我们要学会珍惜我们生活的每一天,因为,这每一天的开始,都将是我们余下生命之中的第一天。除非我们即将死去。

分类:Life

执子之手,与子偕老

九月 5, 2007 2 条评论

一直欣赏这样一种爱情:没有太多的轰轰烈烈惊天动地,有的是象流水一样绵延不断的感觉;没有太多的海誓山盟花前月下,有的是相对无言眼波如流的默契……这该是一种“执子之手,与子偕老”的感觉吧,在陌生的人群中,在迷失和彷徨间,你却始终安详而从容——因为你知道,冥冥之中,自有一双属于你的双手,它们紧紧地握住你,陪你走过所有的阴天和所有的艳阳天,直到一生一世。

在我们平凡的生命里,本来就没有那么多琼瑶式的一见钟情,没有那么多甜蜜得催人泪下、痛苦得山崩地裂的爱情故事:在百丈红尘中,我们扮演的是自己,一些平平凡凡的生生死死的普通人。于是我们珍惜爱情,珍惜迎面而来的、并不惊心动魄的感情。

在这种爱情故事里,男主人公和女主人公不一定是要一见钟情的,最初他们可能会象陌生人一样擦身而过,象最平常的朋友一样,见面只打一声招呼,笑一笑,然后远去。之后有一天,在暮色里,你忽然发现她的背影竟是如此的让你心动;一种让你心疼的怜惜就这样不经意地撞中了你,你这才发现,不知不觉地,习惯了擦身而过的她已经走入了你的生命,于是你们就开始了一段美丽的爱情。

爱情都是美丽的,虽然你们的爱情或者并不动人;恋爱中的人们都是美丽的,虽然你们或者都很平凡。舒婷描绘过这样一道风景:大街上,一个安详的老妇人和一个从容的老人微笑着,从不同的方向面对面地走近,走近;然后是微笑着,鼻间顶着鼻间地站着,双手紧紧地系在一起,身后西下的阳光把他们的头发和笑容染成一片暖暖的黄,身旁的人们被他们的幸福染成一片温暖。

起初你们还在怀疑这种爱情,因为它毕竟不象当初设想的那样完美、那样精致、那样浪漫。那只是淡淡的一种感觉,没有大喜也没有大悲,没有九百九十九朵玫瑰也没有魂断蓝桥——只是一种手牵着手,并肩漫步的感觉。他们说婚姻是一座围城,进去了的想出来;而你们就这样手牵着手,坦坦然然地一起走入围城里,互相扶持着,把许许多多毫不动人的日子走成一串风景。这么多年了,回忆起来,所有平凡的片段,所有曾抱怨过、曾怀疑过的时光其实是生命中最温馨的篇章;所有淡淡的日子,其实都是象“空山灵雨”一样,淡得韵味绵长。

执子之手,与子偕老。这该是一种并肩站立,共同凝望太阳的升起、太阳的落下的感觉;该是一种天变地变情不变的感觉。

他们说时间可以冲淡一切,可总有些东西是地久天长海枯石烂的。天上比翼,地上连理,总有一种爱情,是象山一样执着,象海一样深沉,象天空一样广阔的。在下雨的时候,你在车站孤伶伶地望着分飞的雨线,你的心情是无可奈何的沉郁。这时从旁边伸过一把伞来,为你遮住了分飞的雨丝和阴暗的天空;你不用回头,便知道是如山如海如蓝天的他正站在你的旁边了,便有一种极温暖极踏实的感觉涌上心头:雨丝就让它分飞吧,天就让它阴暗吧,此时你已有了一把伞,而你的心情也因此而阳光灿烂。

他们说时间可以让一切蒙上灰尘,可总有些东西是历久常新的。牵在你的手中,所有的人生、所有灿烂或不灿烂的日子都变得崭新而明媚。时光它总是在不停地走,回首之时不觉以是满身尘垢;你却仍然愿意蒙上眼睛,毫不保留地把双手都交给这生生世世的恋人……

执子之手,与子偕老。当你哭泣的时候,有人陪你伤心,倾听你诉说,为你抚平凌乱的发和憔悴的颜容,告诉你明天依旧阳光灿烂;当你笑容明媚的时候,整个世界都和你一起明媚,而他静静地站在一旁,微笑着看着你和阳光一般地灿烂……

执子之手,与子偕老。这该是一幅两个人同撑起一方天空的风景,象两棵独立的大树,你们共同撑起一方天空,枝叶在蓝天下盛放,树根在地底下相互扶持。风也罢霜也罢,雨也罢雪也罢,执子之手,每一刻都是如此的美好,每一刻都是一首动人的情诗,每一刻都值得用所有的时光去回味……

也许也不回味,只是紧紧握住你的手,什么话也不说,慢慢地陪你走过今生今世,来生来世……

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

分类:未分类

重回MSN,重整MSN Space

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

出院 了

六月 29, 2006 2 条评论
1.我TMD的终于出院了,快闷死了
2.想念大家
3.今天走在南京的路上,感觉很凄凉很失落,突然间物4人非,突然间发现自己在南京没了着落
4.明天回家
5.真的很感激大家
分类:Life