Racial attitudes have not improved in the four years since the United States elected its first black president, an Associated Press poll finds, as a slight majority of Americans now express prejudice toward blacks whether they recognize those feelings or not.

Those views could cost President Barack Obama votes as he tries for re-election, the survey found, though the effects are mitigated by some people’s more favorable views of blacks.

Racial prejudice has increased slightly since 2008 whether those feelings were measured using questions that explicitly asked respondents about racist attitudes, or through an experimental test that measured implicit views toward race without asking questions about that topic directly.

Fifty-one percent of Americans now express explicit anti-black attitudes, compared with 48 percent in a similar 2008 survey. When measured by an implicit racial attitudes test, the number of Americans with anti-black sentiments jumped to 56 percent, up from 49 percent during the last presidential election. In both tests, the share of Americans expressing pro-black attitudes fell.

“As much as we’d hope the impact of race would decline over time … it appears the impact of anti-black sentiment on voting is about the same as it was four years ago,” said Jon Krosnick, a Stanford University professor who worked with AP to develop the survey.

Most Americans expressed anti-Hispanic sentiments, too. In an AP survey done in 2011, 52 percent of non-Hispanic whites expressed anti-Hispanic attitudes. That figure rose to 57 percent in the implicit test. The survey on Hispanics had no past data for comparison.

The AP surveys were conducted with researchers from Stanford University, the University of Michigan and NORC at the University of Chicago.

Experts on race said they were not surprised by the findings.

“We have this false idea that there is uniformity in progress and that things change in one big step. That is not the way history has worked,” said Jelani Cobb, professor of history and director of the Institute for African-American Studies at the University of Connecticut. “When we’ve seen progress, we’ve also seen backlash.”

Obama has tread cautiously on the subject of race, but many African-Americans have talked openly about perceived antagonism toward them since Obama took office. As evidence, they point to events involving police brutality or cite bumper stickers, cartoons and protest posters that mock the president as a lion or a monkey, or lynch him in effigy.

“Part of it is growing polarization within American society,” said Fredrick Harris, director of the Institute for Research in African-American Studies at Columbia University. “The last Democrat in the White House said we had to have a national discussion about race. There’s been total silence around issues of race with this president. But, as you see, whether there is silence or an elevation of the discussion of race, you still have polarization. It will take more generations, I suspect, before we eliminate these deep feelings.”

The surveys found that by virtue of racial prejudice, Obama could lose 5 percentage points off his share of the popular vote in his Nov. 6 contest against Republican challenger Mitt Romney. But Obama also stands to benefit from a 3 percentage-point gain due to pro-black sentiment, researchers said. Overall, that means an estimated net loss of 2 percentage points.

Racial prejudice is not limited to one group of partisans. Although Republicans were more likely than Democrats to express racial prejudice in the questions measuring explicit racism (79 percent among Republicans compared with 32 percent among Democrats), the implicit test found little difference between the two parties. That test showed a majority of both Democrats and Republicans held anti-black feelings (55 percent of Democrats and 64 percent of Republicans), as did about half of political independents (49 percent).

Obama faced a similar situation in 2008, the survey then found.

The Associated Press developed the surveys to measure sensitive racial views in several ways and repeated those studies several times between 2008 and 2012.

The explicit-racism measures asked respondents whether they agreed or disagreed with a series of statements about black and Hispanic people. In addition, the surveys asked how well respondents thought certain words, such as “friendly,” “hardworking,” “violent” and “lazy” described blacks, whites and Hispanics.

The same respondents were also administered a survey designed to measure implicit racism, in which a photo of a black, Hispanic or white male flashed on the screen before a neutral image of a Chinese character. The respondents were then asked to rate their feelings toward the Chinese character. Previous research has shown that people transfer their feelings about the photo onto the character, allowing researchers to measure racist feelings even if a respondent does not acknowledge them.

Results from those questions were analyzed with poll takers’ ages, partisan beliefs, views on Obama and Romney and other factors, which allowed researchers to predict the likelihood that people would vote for either Obama or Romney. Those models were then used to estimate the net impact of each factor on the candidates’ support.

All of the surveys were conducted online. Other research has shown that poll takers are more likely to share unpopular attitudes when they are filling out a survey using a computer rather than speaking with an interviewer. Respondents were randomly selected from a nationally representative panel maintained by GfK Custom Research.

Results from each survey have a margin of sampling error of approximately plus or minus 4 percentage points. The most recent poll, measuring anti-black views, was conducted Aug. 30 to Sept. 11.