1.zero-based indexing

[size=medium]Just like an ordinary primitive byte array, ByteBuf uses zero-based indexing. It means the index of the first byte is always 0 and the index of the last byte is always capacity - 1. For example, to iterate all bytes of a buffer, you can do the following, regardless of its internal implementation:

[i]ByteBuf buffer = ...;
for (int i = 0; i < buffer.capacity(); i ++) {
byte b = buffer.getByte(i);
System.out.println((char) b);
}[/i][/size]
% Read two images %image1 = imread('1.png'); %image2 = imread('2.png'); image1 = imread('40.bmp'); image2 = imread('乙醇.bmp'); % Down-sample the image to half its original resolution downsampled_image1 = imresize(image1, 0.1); downsampled_image2 = imresize(image2, 0.1); % Convert images to grayscale image1 = rgb2gray(downsampled_image1); image2 = rgb2gray(downsampled_image2); % Convert images to double precision for computations image1 = double(image1); image2 = double(image2); % Determine size of images [n, m] = size(image1); % Initialize matrices for displacement fields u = zeros(n, m); v = zeros(n, m); % Set window size for correlation (odd number to have a central pixel) window_size = 15; half_window_size = (window_size-1)/2; % You need to initialize these variables before the loop uTemp = zeros(n, m); vTemp = zeros(n, m); for i = 1+half_window_size : n-half_window_size fprintf('The value of i is: %d\n', i); parfor j = 1+half_window_size : m-half_window_size fprintf('The value of j is: %d\n', j); % Extract sub-window from image1 sub_window1 = image1(i-half_window_size : i+half_window_size, j-half_window_size : j+half_window_size); % Skip this sub-window if all its values are the same if numel(unique(sub_window1)) == 1 continue; end % Correlate this with image2 within a search area (here, the whole image) correlation = normxcorr2(sub_window1, image2); % Find the peak correlation [ypeak, xpeak] = find(correlation == max(correlation(:))); % If there are multiple, just take the first one ypeak = ypeak(1); xpeak = xpeak(1); % Compute displacements (be careful about off-by-one due to zero-based and one-based indexing) uTemp(i,j) = ypeak - i; vTemp(i,j) = xpeak - j; end end % Copy the temporary variables back to the original ones after the loop u = uTemp; v = vTemp; % Flatten the images into 1D arrays image1_1D = image1(:); image2_1D = image2(:); % Compute the correlation coefficient correlationCoefficient = corrcoef(image1_1D, image2_1D); % The correlation coefficient is the value at position (1,2) or (2,1) in the output matrix correlationCoefficient = correlationCoefficient(1,2); fprintf('The value of correlationCoefficient is: %d\n', correlationCoefficient); % Display original images and displacement field figure, subplot(1,3,1), imshow(image1, []), title('Image 1'); subplot(1,3,2), imshow(image2, []), title('Image 2'); subplot(1,3,3), quiver(u, v), title('Displacement Field');
06-03
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值