How can I set a specific bin size?
Show older comments
I want to do horizontal binning of .tif images. I previously was doing this by setting the number of breakpoints I wanted to create binning to collect data from an image. However, instead of setting a number of breakpoints in which the bin size is dependent, I want to set a certain bin size due tho the number of pixels in each size. Only issue is, I'm not quite sure where to start. Any suggestions?
3 Comments
Walter Roberson
on 18 May 2023
How are you doing the horizontal binning? Which function are you calling?
amia
on 18 May 2023
Cris LaPierre
on 18 May 2023
Copy/paste is preferred over screen shots.
Answers (1)
Walter Roberson
on 18 May 2023
breakpoints = 1 : FixedBinSize : sz(2)-FixedBinSize+1;
%...
for xvalues = 1:length(breakpoints)-1
im = qudrant(:, breakpoints(xvalues):breakpoints(xvalues+1)-1, :);
%...
end
Note that with a fixed bin size you have the problem that the image might not be an exact multiple of the bin size. The above code deals with the situation by not generating any partial image. You need to decide whether in your situation you want to instead
- use a final smaller image
- pad the boundary
If you want to use a final smaller image then after setting
breakpoints = 1 : FixedBinSize : sz(2)-FixedBinSize+1;
add in
if breakpoints(end) ~= sz(2); breakpoints(end+1) = sz(2); end
Categories
Find more on Genomics and Next Generation Sequencing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!