我试图阅读两个&#b;'在Matlab中通过char lines[50];
int numOfLines = 0;
int numOfWords = 0;
int i, j;
int wordsPerLine[50]; //Unused at this point
for(i = 1; i <= 1000; i++){
fgets(lines,50,stdin);
if (strcmp(lines, ".\n") == 0){
break;
}
for (j = 0; j < strlen(lines); j++){
if(lines[j] == ' ' || lines[j] == '\n'){
numOfWords++;
wordsPerLine[numOfLines]++; //everything works up until here
}
}
numOfLines++;
}
for (i = 0; i < numOfLines; i++){
printf("words in %d is %d\n", i, wordsPerLine[i]); //trying to print out the array where I'd hope to store them, however I get a bunch of random numbers
}
printf("total words is %d\n", numOfWords);
函数格式化图像。
对于第一张图像,它返回512 * 512 uint8的矩阵,第二张图片返回512 * 512 * 3 uint8。
对imread
进行傅里叶变换后,显示白色图像。任何的想法?
img2
答案 0 :(得分:1)
问题是第二个图像是RGB,fft2
分别在每个通道上执行2D FFT 并返回与输入相同大小的matix。当您尝试显示生成的RGB图像(每个通道是每个通道的FFT)时,它将显示为全白色。
如果您实际想要每个通道的FFT,那么您将需要为每个通道单独显示FFT
% Display red FFT
imshow(log(abs(fftshift(FFT2(:,:,1)))), [0 10]);
您的另一个选择是在进行FFT之前将图像转换为灰度图像
img2 = rgb2gray(img2);
FF2 = ff2(img2);
imshow(log(abs(fftshift(FFT2(:,:,1)))), [0 10]);