和心理系在做的实验,主要是研究基于双眼视差的立体视觉在不同的掩蔽类型以及不同视差条件下的去掩蔽效应。基于双眼视差的立体视觉不改变目标与掩蔽刺激之间的信噪比,但能使不同的刺激被知觉在不同的深度位置上以降低目标信号所受到的掩蔽作用。掩蔽作用依据机制不同,可分为能量掩蔽,即不受双眼立体视觉所造成的主观空间分离影响的;以及信息掩蔽,即可以被主观空间分离的。
实验分为几个阶段,最主要是在阶段II被试在存在掩蔽刺激的情况下判断目标图像中的四个字母是否相同。
我主要负责生成实验材料,以下是一些关键代码:
//旋转任意角度随机字母
Mat letterRandRotateMaskerImage(int tag_location)
{
int target_width=img_width+eye_shift+50;
int target_height=img_width+50;
Mat masker_img(target_height, target_width,CV_8UC3,Scalar(128,128,128));
Rect roi;
roi.y = 0;
roi.height = pics[0].rows;
int ini_height = 0;
int pic_num=pics.size();
int ang_num=angles.size();
while(1)
{
if((ini_height+pics[0].rows) > target_height) break;
//initial roi
roi.x = 0;
while(1)
{
roi.y = ini_height;
int pic_idx = rand()%pic_num;
int rotate_angle = rand()%70;
if((pic_idx==8||pic_idx==9)&&rotate_angle>45)
rotate_angle=rotate_angle-45;
int time_flag=rand()%2;
int ver_flag=rand()%2;
//rotate picture
Mat rota_img = rotateImage(pics[pic_idx], rotate_angle, time_flag,ver_flag);
//get roi
roi.width = rota_img.cols;
roi.height = rota_img.rows;
if(roi.x < 0) roi.x = 0;
if(roi.y < 0) roi.y = 0;
if((roi.x+roi.width) > target_width) break;
if((roi.y+roi.height) > target_height) break;
Mat sub_img(masker_img,roi);
for(int i=0;i<sub_img.rows;i++){
uchar* ptr_rotate=rota_img.ptr<uchar>(i);
uchar* ptr_sub=sub_img.ptr<uchar>(i);
for(int j=0;j<sub_img.cols;j++){
if( (ptr_rotate[j*3]<180)&&(ptr_rotate[j*3+1]<180) &&((ptr_rotate[j*3+2]<180))){
ptr_sub[j*3]=78;
ptr_sub[j*3+1]=78;
ptr_sub[j*3+2]=78;
}
}
}
roi.x = roi.x + pics[pic_idx].cols+2;
}
//next y position
ini_height += pics[0].rows+2;
}
//cout<<"masker ok 2"<<endl;
int video_width=img_width*2+border_width*4+img_shift;
int video_height=img_width+border_width*2;
Mat video_img(video_height,video_width,CV_8UC3,Scalar(0,0,0));
roi.width=img_width;
roi.height=img_width;
roi.x=border_width;
roi.y=border_width;
Mat left_video(video_img,roi);
roi.x=rand()%10;
roi.y=rand()%10;
Mat right_target(masker_img,roi);
roi.x+=eye_shift;
Mat left_target(masker_img,roi);
roi.x=border_width*3+img_shift+img_width;
roi.y=border_width;
Mat right_video(video_img,roi);
if(tag_location==0){
left_target.copyTo(left_video);
right_target.copyTo(right_video);
}
else if(tag_location==1){
left_target.copyTo(right_video);
left_target.copyTo(left_video);
}
else if(tag_location==2){
left_target.copyTo(right_video);
right_target.copyTo(left_video);
}
int center_x=video_img.rows/2;
int center_y=video_img.cols/2;
uchar* p_center=video_img.ptr<uchar>(center_x);
p_center[center_y*3]=255;
p_center[center_y*3+1]=255;
p_center[center_y*3+2]=255;
return video_img;
}
这是最主要的掩蔽刺激,任意旋转角度的字母,主要存在信息掩蔽。还有另外几种掩蔽类型:切割后的字母,随机像素,以及随机相位,都是在此种图像处理的结果。
生成图片其实为左右两幅,用立体镜放映可以使被试看到“立体”效果,当右眼图像内容相对左眼是向右“偏移”时,会有远离人眼的效果,即掩蔽刺激在目标刺激之后。
//生成随机目标图像
Mat targetImage(int tag_same)
{
int id_same,id_dif;
if(tag_same){
id_same=rand()%26;
id_dif=id_same;
}else{
int dif_tmp=rand()%diff_size;
id_same=diffs[dif_tmp];
if(dif_tmp%2==0){
id_dif=diffs[dif_tmp+1];
}else{
id_dif=diffs[dif_tmp-1];
}
}
int id_location=rand()%4;
int textWidth=pics[id_same].cols;
int textHeight=pics[id_same].rows;
int x[4],y[4];
x[0] = img_width/2-textWidth-text_shift;
y[0] = img_width/2-textHeight/2;
x[1] = img_width/2-textWidth/2;
y[1] = img_width/2-textHeight-text_shift;
x[2]=img_width/2+text_shift;
y[2]=y[0];
x[3]=x[1];
y[3]=img_width/2+text_shift;
Mat targetImage(img_width,img_width, CV_8UC1, 255);
Mat subImage1(targetImage,Rect(x[0],y[0],textWidth,textHeight));
Mat subImage2(targetImage,Rect(x[1],y[1],textWidth,textHeight));
Mat subImage3(targetImage,Rect(x[2],y[2],textWidth,textHeight));
Mat subImage4(targetImage,Rect(x[3],y[3],textWidth,textHeight));
Mat aGrayImg;
cvtColor(pics[id_same], aGrayImg, CV_BGR2GRAY);
if(id_location!=0)
aGrayImg.copyTo(subImage1);
if(id_location!=1)
aGrayImg.copyTo(subImage2);
if(id_location!=2)
aGrayImg.copyTo(subImage3);
if(id_location !=3)
aGrayImg.copyTo(subImage4);
int difTextWidth=pics[id_dif].cols;
int difTexttHeight=pics[id_dif].rows;
int difX=0;
int difY=0;
if(id_location==0){
difX = img_width/2-difTextWidth-text_shift;
difY = img_width/2-difTexttHeight/2;
}
else if(id_location==1){
difX= img_width/2-difTextWidth/2;
difY = img_width/2-difTexttHeight-text_shift;
}
else if(id_location==2){
difX=img_width/2+text_shift;
difY=img_width/2-difTexttHeight/2;
}
else{
difX=img_width/2-difTextWidth/2;
difY=img_width/2+text_shift;
}
Mat subDifImage(targetImage,Rect(difX,difY,difTextWidth,difTexttHeight));
Mat bGrayImg;
cvtColor(pics[id_dif], bGrayImg, CV_BGR2GRAY);
bGrayImg.copyTo(subDifImage);
// imshow("target",targetImage);
return targetImage;
}
*生成的目标刺激和掩蔽刺激后面要合成一张图,目标刺激的左右眼图是在同一视差
还有保证各种刺激条件的随机性的代码:
void randVector(vector<int>&same_ids, vector<int>&type_ids, vector<int>&location_ids, int numbers,int tag)
{
for(int i=0;i<numbers;i++){
same_ids[i]=0;
type_ids[i]=0;
location_ids[i]=0;
}
int same_number=numbers/2;
//type_ids 固定,same_ids 和 location_ids 随机
if(tag==0){
int same_count=0;
while(same_count<same_number){
int rand_id=rand()%numbers;
if(same_ids[rand_id]==0){
same_ids[rand_id]=1;
++same_count;
}
}
int same_location_number=same_number/3;
for(int s=0;s<2;s++){
for(int t=1;t<3;t++){
int location_count=0;
while(location_count<same_location_number){
int rand_id=rand()%numbers;
if(same_ids[rand_id]==s&&location_ids[rand_id]==0){
location_ids[rand_id]=t;
++location_count;
}
}
}
}
} //end of tag==0
//location_ids 固定,type_ids 和 same_ids 随机
else if(tag==1){
int same_count=0;
while(same_count<same_number){
int rand_id=rand()%numbers;
if(same_ids[rand_id]==0){
same_ids[rand_id]=1;
++same_count;
}
}
int type_numbers=same_number/4;
for(int s=0;s<2;s++){
for(int t=1;t<4;t++){
int type_count=0;
while(type_count<type_numbers){
int rand_id=rand()%numbers;
if(same_ids[rand_id]==s&&type_ids[rand_id]==0){
type_ids[rand_id]=t;
++type_count;
}
}
}
}
}// end of tag==1
//location_ids ,type_ids 和 same_ids 都随机
else if(tag==2){
int same_count=0;
while(same_count<same_number){
int rand_id=rand()%numbers;
if(same_ids[rand_id]==0){
same_ids[rand_id]=1;
++same_count;
}
}
int same_location_number=same_number/3;
for(int s=0;s<2;s++){
for(int t=1;t<3;t++){
int location_count=0;
while(location_count<same_location_number){
int rand_id=rand()%numbers;
if(same_ids[rand_id]==s&&location_ids[rand_id]==0){
location_ids[rand_id]=t;
++location_count;
}
}
}
}
int same_type_number=same_location_number/4;
for(int s=0;s<2;s++){
for(int l=0;l<3;l++){
for(int t=1;t<4;t++){
int type_count=0;
while(type_count<same_type_number){
int rand_id=rand()%numbers;
if(same_ids[rand_id]==s&&location_ids[rand_id]==l&&type_ids[rand_id]==0){
type_ids[rand_id]=t;
++type_count;
}
}
}
}
}
}
return ;
}
这段代码写得比较笨拙。。。
分享到:
相关推荐
冈萨雷斯 数字图像处理(第三版)matlab代码 图3.40 非锐化掩蔽和高提升滤波
冈萨雷斯图像处理—非锐化掩蔽和高提升滤波 MATLAB代码 图像处理小白,昨天老师布置了一个作业,搜半天没答案,直接自己写了呜呜呜 clear,clc; % 读取图像 Img = imread(‘moon.jpg’); M = size(Img); if numel(M)>...
matlab 非锐化掩蔽、高提升滤波
HPF 掩码用于检测给定图像中的边缘。3*3 阶这样的 HPF 掩码的示例是 [0 -1 0;-1 4 -1;0 -1 0]。 将由此产生的边缘图像添加到原始图像中以产生清晰的图像。 LPF 掩码矩阵也可用于生成平滑图像。
刚萨雷斯课本第三章部分ppt,里面包含书中图像实现代码,初学者可入
将估计噪声和初步增强语音分别通过可以模拟人工耳蜗模型的gammatone滤波器组进行滤波处理,得到各自的时频表示形式;利用人耳的听觉掩蔽特性,计算含噪语音在时频域的二值掩蔽;利用二值掩蔽得到增强语音。实验结果...
语音掩蔽系统的掩蔽质量研究,王国营,朱维彬,为了实现语音通话过程中近端讲话者私密信息的安全性,提出语音掩蔽系统的模型,该系统由掩蔽声回声抵消器和掩蔽信号发生器两个模
视觉掩蔽可基于知觉到的客体位置,陈晶,周吉帆,本研究利用flash-lag效应分离视觉掩蔽中客体的物理位置和知觉位置,以探讨掩蔽效应是否基于知觉到的客体位置。实验中掩蔽刺激做圆周
常用的掩蔽剂[归类].pdf
用高斯的十五阶导函数的组合来合成满足UWB室内辐射掩蔽的脉冲信号
58基于对象的相对运动执行图像掩蔽的方法和装置_new.pdf
关于基于对象的相对运动执行图像掩蔽的方法和装置的介绍说明.rar
一种声掩蔽智能管控系统的制作方法.docx
次能带卡尔曼滤波结合掩蔽属性噪声语音信号
为了认证立体图像的完整性,提出了一种基于立体视觉掩蔽的非对称立体图像水印方法。首先,根据立体视觉特性,建立立体视觉掩蔽计算模型,设计了立体图像左右视点嵌入不同容量的非对称水印;其次,使用小波变换系数...
基于听觉掩蔽效应的最优幅度谱估计降噪研究,刘勇,俞冬英,本文给出了一种基于听觉掩蔽效应的最优幅度谱估计的语音增强算法。传统的单麦克风语音增强算法可以看做是在降噪程度,语音失真,
基于声音定位和听觉掩蔽效应的语音分离研究
一种基于短时谱估计和人耳掩蔽效应的语音增强算法
代码实现了三中图像锐化的算法,包括基于二阶微分的拉普拉斯算子图像锐化、基于非锐化掩蔽技术的图像锐化,以及基于梯度的图像锐化。这三中锐化算法已经打包成函数,可以轻易调用。这些算法可以对灰度图像、RGB图像...