问题描述
我将不得不提前为这个问题的模糊性道歉。我想帮助一位试图比较两个图像中荧光神经重叠的朋友。
设置如下:
有一个神经和背景标记为红色的图像,以及绿色标记的神经和背景的相同图像。有些神经只标有红色,有些只标有绿色,这很重要。我们想要做的是覆盖红色图像和绿色图像,然后找出哪些神经标记两者(红色和绿色重叠)。
有一个连续体两个标签的强度都很明显(因此有明显的红色和红色斑点的明显线条,绿色相同)。
我在想你能做的是设置红色的阈值强度,并仅使用满足该阈值强度的那些神经重新绘制图像。你也可以为绿色做这件事。然后,通过输出,您可以通过测量在另一个输出中找到的一个输出中的神经组织的百分比来比较重叠神经的比例。
这将是理想的能够生成输出图像,其中重叠区域可以被着色(例如蓝色)。然后,我们可以获取所有重叠为蓝色的输出,并将其覆盖在原始红/绿图像上,以直观地突出显示重叠的神经。
或者(或者组合),你可以将图像转换为字符串,然后在这些字符串中的相同位置查找匹配的字符。
这些都远远超出我的技能等级^ _ ^;
如果有人认为这是可能的,有任何建议可以做更好的工作流程,或者可以指向一些好的阅读或非常感谢。如果你有任何帮助,可以提供帮助。
编辑:Matlab中的这个建议回答了我的问题的开始(如何测量哪些像素超过某个阈值强度)。它们转换为灰度,然后将强度视为白色的像素。然后,我需要生成仅满足阈值强度的像素的输出。
对比度不是很好但是因为它只有8-196而不是0-255的范围,所以我们可以将它标准化到整个范围,然后将阈值标准化为50%,如下所示:
转换red.jpg -separate -delete 1,2 -normalize -threshold 50%r.jpg
给出了这个:
最后,我们采用分离的,标准化的,阈值化的红色和绿色并合成一个空的蓝色通道,大小相同,并将它们放在一起作为新图像的红色,绿色和蓝色通道:
转换r.jpg g.jpg -size 100x100 xc:black -combine result.jpg
这给了我们这个我们在黄色区域看到明亮的红色和绿色。
整个程序实际上只是在终端输入3行:
转换red.jpg -separate -delete 1,2 -normalize -threshold 50%r.jpg
convert green.jpg -separate -delete 0,2 -normalize -threshold 50%g .jpg
convert r.jpg g.jpg -size 100x100 xc:black -combine result.jpg
如果你喜欢这种方法,你可以改变百分比,你可以引入降噪,并且实际上在一个更复杂的命令中完成整个操作,没有中间文件。无论如何,我向你推荐ImageMagick,即使你必须使用Matlab,也许ImageMagick中的这个例子会给你一些工作流程的指示。
额外的例子......如果你为红色通道设置了较低的阈值,你会在输出文件中获得更多的红色像素,所以如果你将红色阈值改为30%,你就会得到这个:
I am going to have to apologize for the vagueness of this question in advance. I'm looking to help a friend who is trying to compare the overlap of flourescent nerves in two images.
The setup is as follows:There is an image of nerves and background labeled in red, and the same image of nerves and background labeled in green. Some nerves only labeled with red, and some only labeled with green, and that's important. What we want to do is overlay the red image and green image, and then figure out which nerves label with both (where red and green overlap).
There is a continuum of intensity for both labels (so there're bright obvious lines of red and dim areas of red speckle, same for green).
I was thinking what you could do is set a threshold intensity for red, and re-plot the image with only those nerves that met that threshold intensity. You could do this for green as well. Then, with the outputs you could compare the proportion of overlapping nerves by measuring the percentage of nerve tissue in one output that is found in the other output.
It would be ideal to be able to generate an output image where overlapping areas could be coloured (e.g. blue). Then, we could take that output where all the overlaps are blue, and overlay it on the original red/green images to visually highlight nerves that overlap.
Alternatively (or in combination), you could convert the images to character strings, and then look for matching characters in the same positions in those character strings.
Either of these is far beyond my skill level ^_^;
If anyone thinks this is possible, has any suggestions for a better workflow to do it, or can point me in the direction of some good reading or a package to figure this out, it would be much appreciated.
Thanks for any help you can offer!
edit: This suggestion in Matlab answers the start of my question I think (how to measure which pixels exceed some threshold intensity). They convert to greyscale, and then look for intensity as pixels that are whitish. I'd then need to generate an output of just those pixels that meet that threshold intensity.
As @JanEglinger suggests, there is no need to use (or pay for) Matlab, especially if your programming skills are limited.
I would suggest ImageMagick which is free and installed on most Linux distros and is also available for OSX and Windows from here. The things you want to do can then be done from the commandline without compilers or development environments and steep learning curves.
Let's take your red image first, just using the commandline in the Terminal, we can look at the statistics like this:
identify -verbose red.jpg | more
Image: red.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: DirectClass
Geometry: 100x100+0+0
Resolution: 72x72
Print size: 1.38889x1.38889
Units: PixelsPerInch
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Pixels: 10000
Red:
min: 8 (0.0313725)
max: 196 (0.768627) <--- Good stuff in Red channel
mean: 46.1708 (0.181062)
standard deviation: 19.4835 (0.0764057)
Green:
min: 0 (0)
max: 13 (0.0509804) <--- Nothing much in Green channel
mean: 3.912 (0.0153412)
standard deviation: 1.69117 (0.00663204)
Blue:
min: 0 (0)
max: 23 (0.0901961) <--- Nothing much in Blue channel
mean: 4.3983 (0.0172482)
standard deviation: 2.88733 (0.0113229)
and see there is little information of any use outside the Red channel. So, we can then separate it into its 3 channels of Red, Green and Blue, and discard the Green and Blue channels like this:
convert red.jpg -separate -delete 1,2 justRed.jpg
which gives us this
The contrast is not very good though because it only ranges from 8-196 instead of 0-255 so we can normalize it to the full range and then threshold at 50% like this:
convert red.jpg -separate -delete 1,2 -normalize -threshold 50% r.jpg
which gives this:
If we now want to do the same for your green image, we would do this but delete the Red and Blue channels this time:
convert green.jpg -separate -delete 0,2 -normalize -threshold 50% g.jpg
giving this:
Finally, we take the separated, normalised, thresholded Red and Green and synthesize an empty Blue channel the same size and put them all together as the Red, Green and Blue channels of a new image:
convert r.jpg g.jpg -size 100x100 xc:black -combine result.jpg
That gives us this where we see in Yellow areas that were bright red and green.
The whole procedure is actually just 3 lines of typing in the Terminal:
convert red.jpg -separate -delete 1,2 -normalize -threshold 50% r.jpg
convert green.jpg -separate -delete 0,2 -normalize -threshold 50% g.jpg
convert r.jpg g.jpg -size 100x100 xc:black -combine result.jpg
If you like the approach, you can vary the percentages, you could introduce noise reduction and also in fact do the whole lot in a single, more complicated command with no intermediate files. Anyway, I commend ImageMagick to you and even if you must use Matlab, maybe this example in ImageMagick will give you some pointers to a workflow.
Extra example... if you set the threshold lower for the Red channel, you will get more Red pixels in the output file, so if you change the Red threshold to say 30%, you will get this:
这篇关于工作流程来比较两个图像中的重叠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!