- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我目前正在研究一个函数,该函数模拟水中粒子随时间的运动。但是,我得到的图像具有极度波动的强度,如下所示:
我正在编写一个函数,使用函数“nfmie”生成一系列图像,显示水中粒子的位置随时间的变化。然而,生成的图像都具有不同的背景强度值(一些图像非常暗,一些是灰色的)。
我的问题是如何更改或重新调整这些图像的强度以保持不变。当使用 mean2 计算每个图像的平均强度时,我得到的值范围为 85 到 90。我想在生成图像之前调整强度,即在我的原始函数中,所以我不需要在外部执行此操作。
下面是我的函数中创建电影的部分(从中拍摄图像)
============================
function finalmiescatter
close all;
clear variables;
colormap('gray')
%======================================
tf_flag=true;
cc_flag=false;
dia=[750*2e-9]; % sphere diameter
rad=dia/2;
ns=[1.5]; % sphere refractive index (complex)
nm=1.333; % outer medium refractive index (real)
lambda=632.8e-9; % vaccuum wavelength here
conv=1;
k=2*pi/lambda*nm; % the wavenumber in medium nm
x=k*dia/2; % the size parameter
m=ns/nm; % the relativere fractive index
%======================================
%======================================
% produce movie here and some paramters
Nx=200;
Ny=200;
N=10;
f=5;
sf=10;
x0=[0,0,0];
v0=[0,0,-200e-9];
Lx=1e-5;
Ly=1e-5;
[x,y,z]=mytimeseries(N,f,dia,sf,x0,v0);
%======================================
tic
vidObj=avifile('movie.avi');
meanintensity=zeros(N,1);
for i=1:N
[nx,ny]=coordinates(Lx,Ly,Nx,Ny,[x(i),-y(i)]);
[xf,yf]=ndgrid(nx,ny);
zf=zeros(size(xf))+z(i);
% generate a frame here
[E,H]=nfmie(an,bn,xf,yf,zf,rad,ns,nm,lambda,tf_flag,cc_flag);
Ecc=sqrt(real(E(:,:,1)).^2+real(E(:,:,2)).^2+real(E(:,:,3)).^2+imag(E(:,:,1)).^2+imag(E(:,:,2)).^2+imag(E(:,:,3)).^2);
clf
meanintensity(i)= mean2(Ecc);
imagesc(nx/rad,ny/rad,Ecc);
rectangle('Position',[-dia(end),-dia(end),dia(end),dia(end)],'Curvature',[1,1]);
axis image;
axis off;
frame=getframe(gca);
cdata_size = size(frame.cdata); % Find the size of the current frame
% Create an empty array that is slightly larger than the current frame (in powers of 4 pixels)
data = uint8(zeros(ceil(cdata_size(1)/4)*4,ceil(cdata_size(2)/4)*4,3));
% "Zero-pad" the current frame by copying the current frame into the empty array
data(1:cdata_size(1),1:cdata_size(2),1:cdata_size(3)) = [frame.cdata];
frame.cdata = data; % Use the zero-padded array as the current image
vidObj = addframe(vidObj,frame);
end
vidObj = close(vidObj);
toc
return
title('$|\vec{E} \cdot \vec{E}^*|$','FontSize',18,'FontName','times','Interpreter','latex');
xlabel('$x/a$','FontSize',18,'FontName','times','Interpreter','latex');
ylabel('$y/a$','FontSize',18,'FontName','times','Interpreter','latex');
set(gca,'FontSize',18,'FontName','Times');
print -depsc e.eps
return
============
function [xp,yp] = coordinates(Lx,Ly,Nx,Ny,xpar)
% Returns coordinates relative to particle position in a spacified frame:
% Lx,Ly = the lab width/height of the frame (m)
% Nx/Ny = the number of pixel in the x and y directions (-)
% xpar a vector of the particle position coordinates [x,y,z]
x=linspace(0,Nx,Nx)*Lx/Nx-Lx/2;
y=linspace(0,Ny,Ny)*Ly/Ny-Ly/2;
xp=x-xpar(1);
yp=y-xpar(2);
return
===========
function [x,y,z]=mytimeseries(N,f,d,sf,x0,v0)
% Returns x y and z coordinates (m) given:
% N = number of frames
% f = frame rate (Hz)
% d = particle diameter
% sf = scale factor (-)
% x0 = initial position (m)
% v0 = drift velocity (m/s)
% Call: [x,y,z]=mytimeseries(1000,10,200e-9,0.5,[0 0 0],0.1e-6*[0 0 -1])
dt=1/f;
delta=d*dt;
x=zeros(N,1);
y=zeros(N,1);
z=zeros(N,1);
x(1)=x0(1);
y(1)=x0(2);
z(1)=x0(3);
for i=2:N
dx=delta*normrnd(0,1)+v0(1)*dt;
dy=delta*normrnd(0,1)+v0(2)*dt;
dz=delta*normrnd(0,1)+v0(3)*dt;
x(i)=x(i-1)+dx;
y(i)=y(i-1)+dy;
z(i)=z(i-1)+dz;
end
if 1==0
figure(1)
plot(x,'-bo'); hold on
plot(y,'-ro'); hold on
plot(z,'-go'); hold on
ylabel('position (m)')
xlabel('frame')
end
============================
那么我有没有办法让这个函数生成的图像保持相同的强度?先感谢您!尼松
最佳答案
尝试归一化,使均值为 0
,方差为 1
。这是使强度图像不受光照变化影响的常用技术,前提是它们属于同一场景。如果您记忆起概率论,这是通过获得 Z 分数来执行的:
回想一下,标准差只是方差的平方根。
这里有一些代码供您试用:
%// Downloaded the images you have provided and
%// converted to double.
im1 = im2double(imread('32oYz.png'));
im2 = im2double(imread('fGDKS.png'));
im3 = im2double(imread('GEsUI.png'));
%// Create normalized images
im1Norm = (im1 - mean(im1(:))) / std(im1(:));
im2Norm = (im2 - mean(im2(:))) / std(im2(:));
im3Norm = (im3 - mean(im3(:))) / std(im3(:));
%// Convert back to uint8
im1Norm = im2uint8(im1Norm);
im2Norm = im2uint8(im2Norm);
im3Norm = im2uint8(im3Norm);
%//Side by side comparison
%// Left column is the original
%// Right column is the processed image
figure;
subplot(3,2,1);
imshow(im1);
subplot(3,2,2);
imshow(im1Norm);
subplot(3,2,3);
imshow(im2);
subplot(3,2,4);
imshow(im2Norm);
subplot(3,2,5);
imshow(im3);
subplot(3,2,6);
imshow(im3Norm);
这是我得到的数字:
底部的那个给我们带来了一些麻烦,因为在波纹的中心有一个如此巨大的强度尖峰,这会扭曲我们的均值和标准差计算。虽然这可能并不完美,但它是您可以开始的东西。
祝你好运!
关于image - 归一化一系列图像的强度以获得恒定强度 - Matlab,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24213717/
我正在为我的雇主编写脚本,以从他们自己的站点获取某些数据。出于一长串原因,我需要从网站上获取数据,如图所示。我发现,其中一些数据是通过 js 调用检索的... 回想起来,我应该选择 Mechanize
我正在使用 python 和 cryptography.io 来签署和验证消息。我可以通过以下方式获得签名的 DER 编码字节表示: cryptography_priv_key.sign(messag
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 6年前关闭。 Improve thi
是否可以区分 ECDF?以下面得到的为例。 set.seed(1) a <- sort(rnorm(100)) b <- ecdf(a) plot(b) 我想对 b 求导以获得它的概率密度函数 (PD
我找到了如何从 navigator.mimeTypes 获取 mimetypes: function GetMimeTypes() { var message = ""; var mi
我在表单中使用单选按钮来隐藏/显示联系人表单中的成员 ID 字段。问题是,当 javascript 更改 html 中包含的隐藏 id 字段(该字段设置为“无”值)时,该字段将不再通过 post 可用
我正在做单元测试。我必须测试所有可能的if..else情况。但是在此if语句中: int32_t i32Res = snprintf(buffer, len, "The%d_String_%d", 0
我有一个 Facebook 应用程序,我想从中获取“喜欢”的总数。我想知道这是否可能。 其中 ID 是应用程序的 ID,ACCESS_TOKEN 是我尝试过的应用程序的当前访问 token : gra
如果我有多个计算实例尝试同时获取同一个 blob 的租约,则似乎经常会成功。我的印象是,一旦租约发出(并因此被客户获得),就不可能同时发出另一个租约? 我希望情况确实如此,我一直在 Azure 中使用
这是我的索引 POST /blogs/1 { "name" : "learn java", "popularity" : 100 } POST /blogs/2 { "name" : "l
我正在将 Symfony2 与 FOSUserBundle 一起使用。我需要为用户获得最高角色。 role_hierarchy: ROLE_CONTRIBUTOR: ROLE_USER
我正在向服务器发送基于 REST 的请求。我希望尽快得到答复,并希望了解可以进行的各种优化。 一种方法当然是在线程中并行发送这些请求。还有哪些其他选项可用于优化此功能? 在服务器上,可以添加哪些配置?
这可能是某种重复的问题,但我似乎找不到合适的解决方案。我正在使用 git4idea.history.GitHistoryUtils.history() 获取提交列表。如果 checkout 其中一个较
我正在做一个程序,可以输入每周的工资和那一周的总工作时间。它应该以小时工资率显示答案。但是我无法显示正确的“centavos/2 decimal places”公式并且它不想使用 float % fl
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
我已经尝试了 mContext.getMainLooper() 和 Looper.getMainLooper()。两者都返回相同的结果,但我想知道哪种方法正确? 我还从 Android 开发人员链接中
我有一个“affiliates”表,其中包含“user”和“referredBy”列。 给定一个用户,我希望获得该用户推荐的所有“n 级”玩家。对于 n=1,我们只关心您直接推荐的玩家数量: SELE
我在 PostgreSQL 9.5 数据库中有两个表: project - id - name task - id - project_id - name - updated_
请帮助我怎样才能得到我预期的结果,在此先感谢并抱歉我的英语不好。 PHP: $dog = implode(',', $data['dogbreed']); $query .= "AND `do
我有 let impulse = CGVectorMake(CGFloat(Constants.impulse), 0) 如何在不创建另一个 CGVector 的情况下得到它的负值? 我正在考虑在 C
我是一名优秀的程序员,十分优秀!