MATLAB exercise program (two-dimensional histogram)

Source: Internet
Author: User

A normal histogram is used to count the number of gray-scale occurrences of pixels in an image.

One dimension of a two-dimensional histogram is a normal histogram, that is, the number of times pixels appear in an image.

The concept of another one-dimensional model is vague. I have read many papers that use the current pixel neighborhood mean gray scale. According to this, it is also possible to use the gray scale of the value in the current pixel neighborhood. You can also use a powerful algorithm to calculate the number of gray-scale occurrences. Therefore, according to this promotion, in fact, it is impossible to form an n-dimensional histogram.

I need to study it again.

Two-dimensional histogram of Lena, one-dimensional is a normal histogram, and two-dimensional is a neighbor mean histogram with a radius of 1:

The Matlab code is as follows:

Clear all; close all1_clc1_img1_imread('lena.jpg '); [m n] = size (IMG); r = 1; % neighboring radius imgn = zeros (m + 2 * r + 1, n + 2 * r + 1); imgn (R + 1: m + R, R + 1: N + R) = IMG; imgn (1: R, R + 1: N + R) = IMG (1: R, 1: N); % extended upper boundary imgn (1: m + R, N + R + 1: n + 2 * r + 1) = imgn (1: m + R, N: N + r); % extend the right boundary imgn (m + R + 1: m + 2 * r + 1, R + 1: n + 2 * r + 1) = imgn (M: m + R, R + 1: n + 2 * r + 1); % extended lower boundary imgn (1: m + 2 * r +: R) = imgn (1: m + 2 * r + 1, R + * r); % extended left boundary hist = zeros (256,256); for I = 1 + R: R + M for j = 1 + R: R + N pix1 = uint8 (imgn (I, j); pix2 = uint8 (mean2 (imgn (I-r: I + R, J-R: J + r); hist (pix1 + 1, pix2 + 1) = Hist (pix1 + 1, pix2 + 1) + 1; endendmesh (double (hist ))

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.