TOKYO (AP) _ Japanese customs officials ruled today that Madonna's pictorial book ''Sex'' violates obscenity standards and cannot be imported unless some of its nude photographs are retouched.

It was not immediately clear how the decision would affect plans for the upcoming Japanese edition of the book.

About 30 copies of the U.S.-published book, in which the pop star acts out and writes about her sexual fantasies, have been confiscated by customs since it went on sale in the United States and Europe last week.

Customs officials, speaking on condition of anonymity, said the books will not be allowed into Japan unless four areas are retouched. They refused to elaborate.

Under Japan's unwritten obscenity standards, virtually anything is allowed, including poses that imply a link between violence and sex, as long as genitals or pubic hair are not shown.

''Sex'' includes several photos showing genitals and pubic hair.

Tokyo-based Dohosha, publisher of the Japanese edition of ''Sex,'' said it was considering how to respond to the customs' decision, including the possibility of revising the sections in question.

The company said its initial run of 150,000 copies will be in bookstores as planned Dec. 1.

Japanese officials have grudgingly started to show some flexibility on the obscenity standard, permitting sales of a few publications with photographs depicting pubic hair and genitals.

Last year, customs officials briefly blocked a shipment of the New York- based ARTnews trade magazine because of an advertisement with a photo of a woman showing pubic hair.

After magazine officials complained, customs finally released the publication, leading to a nationwide debate on whether a more flexible standard of obscenity is needed.